title: Show Secondary Sidebar on Category pages (archive)

text: My site has the following structure where one column is for the main content (articles) and the other one, on the right, is for the sidebar (primary sidebar). The theme allows me to change the layout to three-col, however it's a "side- wide" change. I don't want three columns on main content section. Is there a way to show this second sidebar only on category pages? Here is the code for the secondary sidebar:               <?php     /**      * Alternate Sidebar Template      *      * If a `secondary` widget area is active and has widgets,      * and the selected layout has a third column, display the sidebar.      *      * @package WooFramework      * @subpackage Template      */     global $woo_options;          $selected_layout = 'one-col';     $layouts = array( 'three-col-left', 'three-col-middle', 'three-col-right' );     if ( is_array( $woo_options ) && array_key_exists( 'woo_layout', $woo_options ) )             { $selected_layout = $woo_options['woo_layout']; }          if ( in_array( $selected_layout, $layouts ) ) {          if ( woo_active_sidebar( 'secondary' ) ) {              woo_sidebar_before();     ?>     <aside id="sidebar-alt">     <?php     woo_sidebar_inside_before();     woo_sidebar( 'secondary' );     woo_sidebar_inside_after();     ?>         </aside><!-- /#sidebar-alt -->     <?php         woo_sidebar_after();     } // End IF Statement     } // End IF Statement     ?>      I think there are a few ways to achieve this: 1) We use a conditional function to display the secondary sidebar (which should be on the left of main content) only on category pages. 2) We can disable the secondary sidebar on the single pages. 3) Use CSS to disable sidebar (not sure if this can cause hidden content issue) I wonder if this sounds logical (unfortunately, I am not a "coder") Appreciate your help.


title: Additional Sidebar

text:
Hi I wanted to create extra sidebar in my theme and I am not sure if what I did is correct. In my theme functions.php I found this function:                   function blankslate_widgets_init() {     register_sidebar( array (     'name' => __('Sidebar Widget Area', 'blankslate'),     'id' => 'primary-widget-area',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );     }      and Inside I pasted the new sidebar so it is like that now               register_sidebar( array (     'name' => __('Sidebar Widget Area', 'blankslate'),     'id' => 'primary-widget-area',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );               register_sidebar( array (     'name' => __('Left Sidebar', 'blankslate'),     'id' => 'left_sidebar',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );     }      after I've done this the widget appears in the dashboard perfectly then I add this code where I wanted the sidebar to appear               <?php dynamic_sidebar('left_sidebar'); ?>      and that worked perfectly for me. I'm not sure if this is the correct way and just worried if my theme will crush. Can anyone advise me please?


title: AJAX calendar navigation returns -1

text:
I am trying to pass `$month` and `$year` values via AJAX when previous/next links are clicked, but all I am getting is a `-1` where the content should be. My JavaScript functions and AJAX call is located in a custom page template, `page-calendar.php` and `functions.php`, see all of the code here. To sum up though, here is the relevant AJAX script: In `functions.php`:               /* draw_ajax_calendar($month, $year) function, see link above for that */          // Date variable settings     $month = (int) ($_POST['month'] ? $_POST['month']                                     : ($_GET['month'] ? $_GET['month']                                                        : date('m')));          $year= (int) ($_POST['year'] ? $_POST['year']                                    : ($_GET['year'] ? $_GET['year']                                                        : date('Y')));               // Adding the AJAX hooks     add_action('wp_ajax_nopriv_draw_ajax_calendar', 'draw_ajax_calendar');     add_action('wp_ajax_draw_ajax_calendar', 'draw_ajax_calendar');      Script in `page-template.php` (also calendar-script.js. see below):               function nextMonthSwap(nextMonthVal,nextYearVal) {             jQuery("#calendar-container").html("
LOADING
").show();             var url="<?php echo $_ajax; ?>";             jQuery.post(url, {month: nextMonthVal, year: nextYearVal}, function(data){                 jQuery("#calendar-container").html(data).show();             });             return false;         }              // attach the link event handlers         jQuery(document).ready(function($) {             $('#prev-link').click(function(){ return prevMonthSwap(<?php echo $prevMonthVal; ?>,<?php echo $prevYearVal; ?>)});             $('#next-link').click(function(){ return nextMonthSwap(<?php echo $nextMonthVal; ?>,<?php echo $nextYearVal; ?>)});         });      Finally, the HTML also in `page-template.php`:
              <?php echo draw_ajax_calendar($month,$year); ?>              <a id="prev-link" href="<?php echo $prev_href; ?>">← Previous                                       <a id="next-link" href="<?php echo $next_href; ?>">Next →
      I have referenced this similar post and tried moving my JS from the `page- calendar.php` to `calendar-script.js` and including the script with this in `functions.php`:               function enqueue_calendar_script() {              // embed the javascript file that makes the AJAX request         wp_register_script( 'calendar-script.js', get_bloginfo('stylesheet_directory').'/scripts/calendar-script.js');         wp_enqueue_script( 'calendar-script.js' );              // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)         wp_localize_script( 'calendar-script.js', 'wp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );           }     add_action('wp_head', 'enqueue_calendar_scripts');      Enqueueing the `calendar-script.js` like this reverts to passing the `$month` and `$year` values via the URL. The behavior is the same logged in and logged out and according to the page source, the script is being called. Apologies if this is long winded, trying to be thorough. Any help is greatly appreciated!


title: How do I change the default WordPress e-mail ID for sent e-mail?

text: I have created a blog website at `careerdemo.com` and installed WordPress to run it. When a person signs up, they get an email from the address `wordpress@careerdemo.com` (this is, I guess, a default setting in WordPress). I want to change that, so that e-mails come from my own address,`contact@careerdemo.com`. (So any new user will get e-mails from my own e-mail address, `contact@careerdemo.com`.) How do I customize my FROM e-mail address?


title: Get the values from an array string to work with post__in

text: > Basically i need help to build a proper array to pass as value of `post__in` Basically code has to get featured images of posts **only for selected ids**. I need your help to extract the values of the concerned array string in the right manner as currently the code gives a warning `Warning: implode(): Invalid arguments passed in .../..`. It still displays images though. The issue is it displays images from across all posts instead of **images only from posts with selected ids** , as intended.                $sel_ids = $_SESSION['selected_ids'];           global $wpdb;       require_once('../../../../wp-load.php');           $args = array('post__in' => implode( ', ', $sel_ids ), 'post_type' => 'post');         $posts = get_posts($args);           foreach ($posts as $post) {          echo get_the_post_thumbnail($post->ID, 'coverimage');      }      In the first line of code block above, this string `$sel_ids` carries ids of selected posts. When `echoed` gives `Array`. When `var_dump($sel_ids)` shows               array(2) { [0]=> string(2) "67" [1]=> string(2) "16" }      and `foreach` gives a string such as `6716`. I do not need the `foreach` in my code but giving additional info so that it may help you infer better. The code above is not on a template page, but instead on a separate page. it is actually a form-processor. I need the code to run here as I need to grab those values and email them later. So I have loaded WordPress globals. The session is there to carry array value from the form. * * * UPDATE - @Mamaduka - Here is a relevant part of the source of the email in gmail               Array<img src="http://xxxxxxxxx.com/wp-content/uploads/2014/04/360.jpg">


title: Retrieve each widget separately from a sidebar

text:
I would like to retrieve each widget existing in a sidebar in order e.g. to mix them with posts inside the main loop. I know I can use different widget areas (sidebars) but this approach clutters the widget admin page with some tens of sidebars. To mitigate this, I thought to just add them to a single sidebar and retrieve them consecutively when needed. But I'm stuck. I've no idea on how to retrieve a widget separately. My tentative approach is to use wp_get_sidebars_widgets and the_widget but I'm not able to retrieve the widget class name. Here is a simplified snippet of my code. In this case I'm trying to add a widget every three posts, but is an oversimplification of the logic (since I do not want just to add them regularly) in order to provide you the idea. I'd like to visualize every widget using `the_widget` or any other function. How can I accomplish this? Is it possible?                   <?php          $i = 1;         $widgets = wp_get_sidebars_widgets(); // I KNOW THE USE OF THIS IS DISCOURAGED (PRIVATE) BUT CANNOT FIND ALTERNATIVES.          if ( have_posts() ) : ?>                  <?php while ( have_posts() ) : the_post(); ?>                      <?php                     if ($i%3 == 0){                         echo "
WIDGET #".($i/3)."
";                         the_widget($widgets['homepage-1'][$i/3]); // THIS DOES NOT WORKS SINCE I'M NOT GIVING THE CLASS NAME. HOW TO RETRIEVE IT?                     }                     get_template_part( 'content', get_post_format() );                     $i++;                 ?>                  <?php endwhile; ?>                  <?php _s_paging_nav(); ?>              <?php else : ?>                  <?php get_template_part( 'content', 'none' ); ?>              <?php endif; ?>


title: PasswordHash not found in namespace

text: I'm very new to WordPress development, coming from a pure OO background I'm familiarising myself with object-orientation in PHP / WordPress. I have a class at entities\Member, that get's loaded via an autoloader implementation. This stuff I'm quite comfortable with, and up until now, I've not really used WordPress specific functions in my code. For members, I want to use the built in password hasher function that lives in the pluggable.php file, but for some reason the autoloader tries to 'lookup' the PasswordHash function as a class, which it should not be doing? I've browsed around for possible solutions to this, but it seems to be a limitation in WordPress and it's handling of object-orientation in PHP 5+? How can an 'fool' the autoloader to ignore WordPress functions, if at all possible? I have tried adding the require_once(ABSPATH . 'wp-includes/pluggable.php'); in the Members class, even in the functions.php class, just above the autoloader include. No go.


title: Frontend tag edit/submit form

text: I would like to have a separate page to submit/edit tags. Any user can edit or submit tags. But it should be published only after admin approval. Is there any function available like `wp_insert_tag()`? ## Update: After Kaiser's answer I've tried like this.               $x = wp_insert_term( 'test', 'post_tag', array('description' => 'This is a test tag') );     var_dump($x);      Its working fine. But it gets published automatically. Is it possible to publish it after admin approval?


title: Reusing header.php from Yii application

text: I'm building a website that uses Wordpress as the CMS and is built with Yii framework. All the business logic works fine. Most visible pages are filled with content from Wordpress admin and only the user profile section is built with Yii. My problem is that I would like to reuse the layout of the wordpress pages in the Yii app. Initially I tried to do it in a blank PHP file and everything worked as expected with this code:               <?php     require( '/var/www/wordpress/wp-load.php' );          get_header();     ?>          <div>     some content here     </div>          <?php     get_footer();     ?>      The problem is that when I make a new layout in Yii so that I can reuse the header and footer it crashes and displays blank page. I tried both with `require('/var/www/wordpress/wp-blog-header.php');` and `require( '/var/www/wordpress/wp-load.php' );`. This is the code I use to load wordpress functionality in Yii but unfortunately it does not work.               <?php /* @var $this Controller */     spl_autoload_unregister(array('YiiBase','autoload'));     require( '/var/www/wordpress/wp-load.php' );     get_header();          spl_autoload_register(array('YiiBase', 'autoload'));           ?>      All I see is a completely blank page (no markup). Any help would be much appreciated. Ideally I would like to use `get_header()` and `get_footer()` wordpress functions in Yii layouts/views. Thanks **UPDATE** I checked Apache logs and it seems that the following error is logged when I try to open the page in my browser: `PHP Fatal error: Call to a member function get() on a non-object in /var/www/wordpress/wp-includes/query.php on line 27` Also when I comment out the `get_header();` row the page opens without any errors (and without any styling too). So something prevents get_header() to work property in Yii.


title: Rating based off of number of comments or views

text: Is it possible to have some sort of rating feature based off of x amount of comments or views? ### Example: Instead of saying 200 views, have it say: > "Hot" 400 views, have it say: > "Very Hot" ### something similar to a if else statement > value=200 Echo "hot" if else echo "cold"


title: Custom Taxonomy for multiple Custom Post Types - Taxonomy Archive not working

text: I'm working on a project where I have a custom taxonomy, for example, called `class-formation`, that is shared for two Custom Post Types. On of them is the `product` CPT created by WooCommerce, and the another one is custom made for the project. I can assing the taxonomy to both CPT's. But the problem is when I try to access the taxonomy archive for `class-formation`, I didn't got a 404 not found error, but none posts are returned (`have_posts()` returns `false`) . And a weird thing is happening too: on this page, every custom menu that I have generated using `wp_nav_menu` is missing (I tested with some themes to check if was a theme related issue, but the behavior is the same). ## What I'm doing: in my **functions.php**               <?php          // registering the taxonomy "class-formation"     function theme_register_taxonomy(){              $labels = apply_filters( 'tax_class_formation_labels' ,array(             'name'                       => _x( 'Formações Acadêmicas', 'Taxonomy General Name', 'theme_slug' ),             'singular_name'              => _x( 'Formação Acadêmica', 'Taxonomy Singular Name', 'theme_slug' ),             'menu_name'                  => __( 'Formações', 'theme_slug' ),             'all_items'                  => __( 'Todos as Formações', 'theme_slug' ),             'parent_item'                => __( 'Formação Pai', 'theme_slug' ),             'parent_item_colon'          => __( 'Formação Pai:', 'theme_slug' ),             'new_item_name'              => __( 'Novo nome de Formação', 'theme_slug' ),             'add_new_item'               => __( 'Adicionar nova Formação', 'theme_slug' ),             'edit_item'                  => __( 'Editar Formação', 'theme_slug' ),             'update_item'                => __( 'Atualizar Formação', 'theme_slug' ),             'separate_items_with_commas' => __( 'Separe formações acadêmicas com vírgulas', 'theme_slug' ),             'search_items'               => __( 'Pesquisar formações', 'theme_slug' ),             'add_or_remove_items'        => __( 'Adiciona ou remova formações', 'theme_slug' ),             'choose_from_most_used'      => __( 'Escolha entre as formações mais usadas', 'theme_slug' ),         ) );              $rewrite = array(             'slug'                       => apply_filters( 'tax_class_formation_slug', _x( 'formacao-academica', 'Taxonomy Slug', 'theme_slug' ) ),             'with_front'                 => true,             'hierarchical'               => false,         );              $args = apply_filters( 'tax_class_formation_args', array(             'labels'                     => $labels,             'hierarchical'               => false,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'query_var'                  => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => false,             'rewrite'                    => $rewrite,         ) );              register_taxonomy( 'class-formation', array( 'theme-courses', 'product' ), $args );          }          add_action( 'init', 'theme_register_taxonomy' );          // filtering the archive taxonomy page to get posts with "theme-courses" CPT     add_action( 'pre_get_posts', 'filter_tax_archive', 1 );          function filter_tax_archive( $query ) {         if ( is_admin() || ! $query->is_main_query() )             return;              if ( $query->is_main_query() && $query->is_tax( 'class-formation' ) ) {             $query->set( 'post_type', array( 'theme-courses' ) );             return;         }     }      The `post_type` query var is successfully inserted, but I got an empty loop anyway. Any ideas for what's causing this issue? Thanks for any help! # Edit: The code above is a simplified version of all the code that I'm using. I made a gist with the full code if anyone want to check: https://gist.github.com/diegoliv/274f09e3f3d9094b204c # Edit 02: Maybe there is some conflict with WooCommerce? If I replace the `product` CPT with another one when I'm registering the taxonomy, the taxonomy page works ok. The same happens if I disable WooCommerce. But, with the actual code, when I'm inspecting the global `$wp_query` to check all the arguments used to build the query, there is some arguments coming from WooCommerce.


title: How to create a wp_query that contains both meta_query and tax_query

text: I have a wp_query that works great but I can't have both a meta query and a tax_query in it.               <?php          $event_query = new WP_Query(             array(                'post_type'  => 'event',        // only query events               'meta_key'    => 'event-date',  // load up the event_date meta               'orderby'     => 'meta_value',               'order'       => 'asc',         // ascending, so earlier events first               'posts_per_page' => '-1',               'meta_query'  => array(                  array(         // restrict posts based on meta values                   'key'     => 'event-date',  // which meta to query                   'value'   => date("Y/m/d"),  // value for comparison                   'compare' => '>',          // method of comparison                   'type'    => 'DATE'  )                  ),               'tax_query' => array(                 array(                     'taxonomy'  => 'event_category',                     'field'     => 'slug',                     'terms'     => $term_id,                     'operator'  => 'IN')                          ),                     ) // end array             ); // close WP_Query constructor call          ?>      I am trying to find all the events in taxonomy $term_id and then make sure they are all in the future and order by ASC Any ideas?


title: How to eliminate weird 404 errors in wp-admin?

text: I run a WordPress site with about 70 active plugins. Every so often, I'll get a random error page ("Not Found", though I haven't checked the headers to see if it's a 404) on a `/wp-admin/` page that pops up out of nowhere. Simply trying again resolves the error, however it's quite inconvenient if the error happens during a plugin upgrade (because the auto-reactivation fails). I think this same issue is responsible for certain modules on my Dashboard failing to load sometimes. Given the list of plugins I have installed, does anyone know of issues with or between any of them that might cause this problem? ### Edit: Hosting info: DreamHost; I think the server's running a custom Debian build with Apache httpd


title: Optimizing a Proximity-based Store Location Search on a Shared Web Host?

text:
I've got a project where I need to build a store locator for a client. I'm using a custom post type "`restaurant-location`" and I have written the code to geocode the addresses stored in postmeta using the Google Geocoding API (heres the link that geocodes the US White House in JSON and I've stored the latitude and longitude back to custom fields. I've written a `get_posts_by_geo_distance()` function that returns a list of posts in order of those which are closest geographically using **the formula I found in the slideshow at this post**. You might call my function like so (I'm starting with a fixed "source" lat/long):               <?php     include "wp-load.php";          $source_lat = 30.3935337;     $source_long = -86.4957833;          $results = get_posts_by_geo_distance(         'restaurant-location',         'geo_latitude',         'geo_longitude',         $source_lat,         $source_long);          echo '
';     foreach($results as $post) {         $edit_url = get_edit_url($post->ID);         echo "
{$post->distance}: {$post->location}
";     }     echo '
';     return;      Here's the function `get_posts_by_geo_distance()` itself:               function get_posts_by_geo_distance($post_type,$lat_key,$lng_key,$source_lat,$source_lng) {         global $wpdb;         $sql =<<<SQL     SELECT         rl.ID,         rl.post_title AS location,         ROUND(3956*2*ASIN(SQRT(POWER(SIN(({$source_lat}-abs(lat.lat))*pi()/180/2),2)+         COS({$source_lat}*pi()/180)*COS(abs(lat.lat)*pi()/180)*         POWER(SIN(({$source_lng}-lng.lng)*pi()/180/2),2))),3) AS distance     FROM         wp_posts rl         INNER JOIN (SELECT post_id,CAST(meta_value AS DECIMAL(11,7)) AS lat FROM wp_postmeta lat WHERE lat.meta_key='{$lat_key}') lat ON lat.post_id = rl.ID         INNER JOIN (SELECT post_id,CAST(meta_value AS DECIMAL(11,7)) AS lng FROM wp_postmeta lng WHERE lng.meta_key='{$lng_key}') lng ON lng.post_id = rl.ID     WHERE         rl.post_type='{$post_type}' AND rl.post_name<>'auto-draft'     ORDER BY         distance     SQL;         $sql = $wpdb->prepare($sql,$source_lat,$source_lat,$source_lng);         return $wpdb->get_results($sql);     }      My concern is that the SQL is about as non-optimized as you can get. MySQL can't order by any available index since the _source geo_ is changeable and there's not a finite set of source geos to cache. Currently I'm stumped as to ways to optimize it. Taking into consideration what I've done already the question is: **How would you go about optimizing this use-case?** It's not important that I keep anything I've done if a better solution would have me throw it out. _I'm open to considering almost any solution_ except for one that requires doing something like installing a Sphinx server or anything that requires a customized MySQL configuration. Basically the solution needs to be able to work on any plain vanilla WordPress install. (That said, it would be great if anyone wants to list alternate solutions for others who might be able to get more advanced and for posterity.) ## Resources Found FYI, I did a bit of research on this so rather than have you do the research again or rather than have you post any of these links as an answer I'll go ahead and include them.   * http://jebaird.com/blog/calculating-distance-miles-latitude-and-longitude   * http://wordpress.org/extend/plugins/geolocation/screenshots/   * http://code.google.com/apis/maps/articles/phpsqlsearch.html   * http://www.rooftopsolutions.nl/blog/229   * http://planet.mysql.com/entry/?id=18085   * http://blog.peoplesdns.com/archives/24   * http://www.petefreitag.com/item/622.cfm   * http://www.phpro.org/tutorials/Geo-Targetting-With-PHP-And-MySQL.html   * http://forum.geonames.org/gforum/posts/list/692.page   * http://forums.mysql.com/list.php?23   * http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL   * http://developer.yahoo.com/maps/rest/V1/geocode.html   * http://geocoder.us/ ## Regarding Sphinx Search   * http://sphinxsearch.com/   * https://launchpad.net/wp-sphinx-plugin   * http://forums.site5.com/showthread.php?t=28981   * http://wordpress.org/extend/plugins/wordpress-sphinx-plugin/   * http://wordpress.org/extend/plugins/sphinx-search/   * http://www.mysqlperformanceblog.com/2008/02/15/mysql-performance-blog-now-uses-sphinx-for-site-search/


title: Free/Open-Source Theme Frameworks as an Alternate to Thesis?

text: What good free and open source alternatives exist to the Thesis theme ??


title: Insert new post for each user infinite loop error

text: I wrote this little function to automatically create a post for every user of the blog but it creates an infinite loop (I disabled it to stop it creating new posts). I'm not very skilled in php, I guess the error is in the use of wp_insert_post inside the foreach, but it doesn't work simply putting it outside the braces. How can I make this function insert JUST ONE post for each author? Thanks.               $blogusers = get_users();     foreach ($blogusers as $user) {         $my_post = array(         'post_title'    => $user->display_name,         'post_content'  => 'Bla bla bla.',         'post_status'   => 'publish',         'post_author'   => $user->ID,         'post_type'     => 'custom'         );              wp_insert_post( $my_post );     }


title: How to maintain W3C standards compliance of a theme

text: When I wrote a theme, I made sure it was compliant with XHTML 1.1 and CSS 2.1. Then I added plugins and the theme is no longer compliant with XHTMl 1.1. Then I used Google API font in my CSS and it is longer CSS 2.1 compliant. Is there a way I can keep the compliance without getting rid of the plugins, font etc or should I just ignore the validation errors?


title: Making the Header on the Twenty Ten Theme Less Tall?

text: The question is _How do I make the header on the Twenty Ten theme less tall?_ That question was asked over at the LinkedIn WordPress group that is hidden from search engines so I thought I'd copy my answer to here. I've also made it a community wiki so it doesn't pass reputation to me.


title: Custom Nav Walker sub-menu HTML construct

text:
I've got my Custom Nav Walker set up and it works fine with the main menu items, and displays them how I want. However the same HTML is being applied to the `sub-menu` elements which isn't what I want. I'm aiming to get the `sub-menu` to have the following styling:

Blog 1

Blog 2

Blog 3

Blog 4

      Here is the HTML Structure for the full navigation

                 <img src="<?php echo get_template_directory_uri(); ?>/assets/drawing-pin.png">

Products

                 <img src="<?php echo get_template_directory_uri(); ?>/assets/corner-flick-cyan.png">

Products 1

Products 2

Products 3

Products 4

Products 5

      Here is the HTML call for the wp_nav_menu:
     <?php           $walker = new my_nav_walker;     wp_nav_menu( array( 'theme_location' => 'header-menu', 'menu' => 'ul', 'menu_class' => 'navigation', 'menu_id' => '', 'walker' => $walker ) );                ?>
      Here is the construct for my Custom Walker HTML: (NOTE: I'm really new to this, so this is going to be messy...)               class my_nav_walker extends Walker {            function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {                      $direct = get_template_directory_uri();                      $item_output = $args->before;                 $item_output .= '
';                 $item_output .= '';                 /** This filter is documented in wp-includes/post-template.php */                      $item_output .= '

';                 $item_output .= '

';                 $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;                      $item_output .= '

';                 $item_output .= '';                 $item_output .= '
';                 $item_output .= $args->after;                  }              } // Walker_Nav_Menu      Here's the CSS if needed: PasteBin Link I'm not sure if I'm doing the construct right to get the separate styling that I want. What would you advise? Are there any alternatives? Constructive Criticism on the code? (Don't be too harsh! :P) EDIT -----: I've done some more research into understanding the php code, and I now realise where the defining of the start and end of the sub-menu starts (With start_lvl and end_lvl), but I still don't understand how to separate what code goes to the Parent navigation panes, and which goes to their respective sub- menus. **This is what I'm after with the display of the naviagtion:http://jsfiddle.net/TPD5L/**


title: Pagination with WP_Query not working

text:
I have a custom page template on my site, with a WP_Query pulling in a list of posts. I'd like to implement pagination but just can't seem to get it right. Here's the code I'm using blelow, which pulls in the most recent 2 posts fine, but then doesn't display the 'next' or 'previous' links as you might expect. For clarity, I have a total of 5 posts that meet the criteria in the query and this template is being used as the front page of my blog. Also, the inc-post- listing.php simply pulls in certain info from each post, like the thumbnail, title and permalink. I'm sure I'm missing something obvious so any help is very much appreciated.                <?php              $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;             // WP_Query arguments             $args = array (                 'post_type'              => 'post',                 'post_status'            => 'publish',                 'posts_per_page'         => '2',                 'paged'                  => $paged             );                  // The Query             $posts = new WP_Query( $args );                  // The Loop             if ( $posts->have_posts() ) {                 while ( $posts->have_posts() ) {                     $posts->the_post();                      include('inc-post-listing.php');                     }             } else {                 // no posts found             }                  // Restore original Post Data             wp_reset_postdata();         ?>
<?php posts_nav_link(' ','Previous Page','Next Page'); ?>

<?php posts_nav_link(' ','Go Back','Show More Tips'); ?>


title: Removing Mutlisite lines stop DB connection

text: I'm trying to revert my mutlisite to a single site and following a guide it recommends removing the following                   /*define( 'MULTISITE', true );*/     define( 'MULTISITE', false );     define( 'SUBDOMAIN_INSTALL', false );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'www.dreamdoors.co.uk' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      and also to make `define('WP_ALLOW_MULTISITE', true);` to false I've commented out the first part and changed the second path but then it says can not find Database connection.


title: Fancybox loading small white square

text:
I know there is a similar topic with same title, but my problem is not the same.Fancybox was working perfectly in my html template, but after converting it to wordpress, images are not showing in the popup box, I can only see a square white box here is my code:               <?php $args = array( 'post_type' => 'portfolio' );     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post(); ?>
                       <?php the_post_thumbnail(); ?>
             <a href="<?php the_permalink(); ?>" class="project-title"><?php the_title(); ?>             <a href="<?php get_the_post_thumbnail(); ?>" class="project-img fancybox">             <a href="<?php the_permalink(); ?>" class="project-link">

     <?php endwhile; ?>      & here is the js:               $(".fancybox").fancybox({                  padding     : 0,             margin      : 100,             openEffect  : 'elastic',             closeEffect : 'elastic',             openSpeed   : 400,             closeSpeed  : 400,                  helpers : {                 overlay : {                     css : {                         'background' : 'rgba(0, 0, 0, 0.75)'                     }                 }             }         });      I'm not a pro. so couldn't find the mistake myself. what should I do?


title: Linking text within textarea of custom meta box

text: I'm using 'Meta Box Script for WordPress' to create custom meta boxes and everything is working great...except the following: We have a textarea that we want to act, basically as another WP the_content (It's for hidden content that is only shown once a link to show hidden content is clicked). My end-users want to be able to put something like the following in the box: `This is some pretty <a href="#">linked text</a>.` I'm using the following code in my template to show the custom meta box content: `<?php echo get_post_meta(get_the_ID(), 'oc_code', true); ?>` The content it shows is exactly like this (I'm guessing it's not parsing, if that's the correct phrase, the URL): `This is some pretty <a href="#">linked text</a>.` What can I do to show a clickable href within the template without adding more custom fields/meta boxes? I was looking at esc_attr, esc_url, etc. but don't know that that is the solution. TIA!


title: get_posts assigned to a specific custom taxonomy term, and not the term's children

text: Say I have the following taxonomy terms:               Term 1       Term 1.1       Term 1.2     Term 2       Term 2.1      How can I get only posts that are assigned to Term 1 and not include those that are assigned to Term 1.1 or Term 1.2? For example:               $pages = get_posts(array(       'post_type' => 'page',       'numberposts' => -1,       'tax_query' => array(         array(           'taxonomy' => 'taxonomy-name',           'field' => 'id',           'terms' => 1 // Where term_id of Term 1 is "1".         )       )     );      is also giving me posts that have Terms 1.1 and 1.2 assigned. Thanks.


title: jQuery Drill Down iPod Menu FOUC and Selecting Current page

text: I'm using Drill Down Ipod Menu and I'm really like the style of showing submenus , but I have two problems with it. 1-when i load a page it shows all submenus open for a second and I experience a Flash of Unstyled Content , it was good for a while when I changed style css but it backed again (i don't know if there's a relation between css file and the problem). my list of active plugins is below (I had some others that i deleted them): 1-Bulk Post Creator Plus 2-Cat + Tag Filter 3-Category Grid View Gallery 4-cforms 5-Custom Field Template 6-ShowID for Post/Page/Category/Tag/Comment 7-SwfObj 8-vSlider 9-wp-jalali how can I prevent showing my menu unstyled ? 2- when I navigate from a submenu to my homepage (from a link outside of menu) menu stay in previous state , i know it use cookies , but is there anyway to show current page instead of using cookies ? if it's impossible to solve this problems what plugin can I use instead to have folding menus from wordpress custom menus (not pages and categories ) ? sorry for my bad english thanks in advancce


title: dbDelta not doing what it says

text: Okay so I must have read hundreds of wordpress answers, google results etc on different people having trouble with dbDelta creating tables for their plugins. Ive tried many variations based off of those answers to see if it would do the trick but this code below does not seem to create the table. Even though the returned data from dbDelta says it created the table, if there is any help anyone can give me or see the error that I've made, I would be very grateful.               function activation() {       // Install table       global $wpdb;            $sql = "CREATE TABLE ".$this->table_name." (         id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,         PRIMARY KEY (id),           user_id BIGINT(20) NOT NULL UNSIGNED,           KEY user_id (user_id),             created DATETIME DEFAULT '0000-00-00 00:00:00'  NOT NULL,             url VARCHAR(55) DEFAULT '' NOT NULL,       );";            var_dump($sql);            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );       var_dump(dbDelta( $sql ));            add_option( "invite_db_version", $invite_db_version );     }      This function is registered to the activation hook in the constructor of my plugin class `register_activation_hook( __FILE__, array( &$this, 'activation' ) );`


title: wp_schedule_event not working?

text: I cannot get a Wordpress cron to trigger. I am trying to run this code to see if I can get an email sent to me hourly. It's taken directly from the Wordpress examples here: http://codex.wordpress.org/Function_Reference/wp_schedule_event. Except I removed underscores (see caveat in documentation). The code is running in my theme functions.php file. The cron seems to be registered but the `prefixdothishourly` function does not get fired (as far as I can tell.)               add_action( 'wp', 'prefixsetupschedule' );          /**      * On an early action hook, check if the hook is scheduled - if not, schedule it.      */     function prefixsetupschedule() {         if ( ! wp_next_scheduled( 'prefixhourlyevent' ) ) {             wp_schedule_event(time(), 'hourly', 'prefixhourlyevent');         }     }          add_action( 'prefixhourlyevent', 'prefixdothishourly' );          /**      * On the scheduled action hook, run a function.      */      function prefixdothishourly() {          return wp_mail("me@example.com", "Notification TEST", "TEST", null);      }


title: Wordpress in own directory not working

text: I have a site with a blog section (well, I'm trying to create the blog section now..) WordPress is installed (original install; not transferred from root) in `/blog/`. Post links (for example, when I click on the Hello World post that was autogenerated,) lead to the TLD. So if I click on it, instead of taking me to http://www.example.com/blog/?p=1, it takes me to http://www.example.com/?p=1. (The current TLD is occupied with an existing index page, so redirecting everything from `/` to `/blog/` won't work. A new subdomain would also be somewhat inconvenient at the moment, and I'd like to avoid that for aesthetic and site structure reasons, as well.) **I've already configured the site's URL in Settings > General > WordPress Address and Site Address.** That did not fix the problem. WordPress 3.9.1 on PHP 5.2.17.


title: Page template with custom html fields inside a content

text: I'm writing a custom page template and I want to do something like this: after typing tag inside page content, for example [custom-email-form] I want to place inside the content some html5 email form. How to achieve that? Thanks.


title: Paginated Taxonomy Term Archive including one post per term

text:
I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in _all_ the taxonomies. Is there a way I can limit the number of taxonomies displayed to a set number per page and paginate them?               // Set post type     $post_type = 'prints';          // Get all the taxonomies for this post type     $taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );          foreach( $taxonomies as $taxonomy ) :               // Get every "category" (term) in this taxonomy to get the respective posts         $terms = get_terms( $taxonomy );              foreach( $terms as $term ) :                  // Query to show first post in taxonomy             $posts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=1" );                  if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
                 <a href="<?php esc_url( the_permalink() ); ?>">                     <?php the_post_thumbnail ('medium'); ?>
<?php echo $term->name; ?>

<?php             endwhile; endif;              endforeach;          endforeach;


title: how to add Custom menu item like User name in Header Menu only

text:
I am new to Wordpress I am setting up wordpress Site which has 3 Menus   * Top menu   * Header Menu   * Footer Menu  My issue is I need to add the User name to My Top menu Only when User is Logged in But using below Code snippet it adds the Custom menu Item in all the Menus the Below Code i found while googleing the Solution for the above Query               function my_custom_menu_item($items)     {         if(is_user_logged_in())         {             $user=wp_get_current_user();             $name=$user->display_name; // or user_login , user_firstname, user_lastname             $items .= '
Welcome '.$name.'
';         }        return $items;     }     add_filter( 'wp_nav_menu_items', 'my_custom_menu_item');      This is my Top menu Structure **if User is not logged in**   * My Account      * Login     * Signup     * Lost Password **if User is Logged In**   * Welcome Nikhil      * Profile     * Change Password     * Logout     * blogs


title: How to take list of words and insert them as terms to become tags of a post

text:
I am working on a plugin that will take words with a certain number of characters from a post title and create a list of suggested tags in my Tag Suggester meta box.   I have created the function to find and display the words that meet my criteria. How do I take that list of words and insert them as terms to become tags for a post. Here is what I have so far:               <?php     //renders html for metabox     function tagsuggester_display_meta_box( $post, $args ) {        wp_nonce_field( plugins_url( __FILE__ ), 'tagsuggester_plugin_noncename' );     ?>
List of available tags:
     <?php         //get_the_title()         $title = get_the_title();          $title_array = explode(' ', $title);         foreach( $title_array as $word ) {             //var_dump( $word );             $word_length = strlen($word);             if ( $word_length > 3 )  {                 //echo  $word;                 echo '<input type="checkbox" name="tagsuggester" value="tagsuggester"> '.$word.'
';             }          }         $tags = get_terms( 'post_tag', array( 'search' => $title_array) );     }          //save the metabox content     function tagsuggester_save_meta_box( $post_id, $post ) {          // Do not save during autosave routines     if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )         return;     // Verify permissions before saving     if ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) {         if ( ! current_user_can( 'edit_page', $post_id ) ) {             return;         }     } else {         if ( ! current_user_can( 'edit_post', $post_id ) ) {             return;         }     }          }          add_action( 'save_post', 'tagsuggester_save_meta_box', 10, 2 );


title: file_get_contents_curl pulling wrong values

text: I'm using file_get_contents_curl to get the facebook likes of the post and store them in my database.                $fb = json_decode(file_get_contents_curl('http://graph.facebook.com/?id='.get_permalink($post->ID)));                 if( !isset( $fb->likes) && isset($fb->shares) )                 {                     $fb->likes = $fb->shares;                 }      Everything worked well until I added more posts (now 700+). The pulling of the likes needed more and more time. Now the script manages to get the right amount of Facebook likes for SOME posts, but for some other posts it just pulls an empty value. So some posts with lets say, 8 FB-Likes, still get the value of 0 FB likes written to the database. My curl function:               function file_get_contents_curl($url)      {         if ( function_exists('curl_init') )          {             $ch = curl_init();                  curl_setopt($ch, CURLOPT_HEADER, 0);             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.             curl_setopt($ch, CURLOPT_URL, $url);                  $data = curl_exec($ch);                  if ($data === FALSE) {                 $data =  "cURL Error: " . curl_error($ch);             }                  curl_close($ch);         } else {             $data = $url;         }         return $data;     }


title: Hide meta box for everything BUT a certain custom post type

text: I need to retain tag taxonomy for a single custom post type, but am struggling with it. Is there a way to remove this meta box for everything BUT? * * * `remove_meta_box('tagsdiv-post_tag', 'post', 'normal');` Will remove the tags from normal posts (desired), but it means they're also removed from ALL custom post types. I can remove the meta box for individual custom post types, like so: `remove_meta_box('tagsdiv-post_tag', 'cars', 'normal');` `remove_meta_box('tagsdiv-post_tag', 'hotels', 'normal');` etc. But that means I have to leave tags available on normal posts (undesired). So I guess I want something like this, to remove the meta box from everything apart from (e.g.) `airports`: `remove_meta_box('tagsdiv-post_tag', '!airports', 'normal');` Any ideas?


title: Localize variable for multiple Shortcodes

text:
I have this code for flexslider Shortcode               add_shortcode('flexslider', function($atts){     global $post;     $ids = explode(',', $atts[ids]);          $uniqid = uniqid();     wp_enqueue_script( 'shortcode_flexslider');     wp_localize_script( 'shortcode_flexslider', 'slider', array('id' => $uniqid));           foreach( $ids as $id ) {         $imgLinks       = wp_get_attachment_image_src($id, large);         $imgThumb       = wp_get_attachment_image_src($id, thumbnail);              $slider     .= '
'.$imgCaptionContent.'
';         $carousel   .= '

';      }     $structure ='

'                 .$slider.                 '

'.                      '

'                 .$carousel.                 '

';        });      I put `uniqid` for slider and carousel ids to can put more one flexslider Shortcode in the same post and I localize the `uniqid` to shortcode_flexslider JS file to find slider and carousel ids               $('#carousel'+slider.id).flexslider({       //        asNavFor: '#slider'+slider.id       //     });          $('#slider'+slider.id).flexslider({      //       sync: '#carousel'+slider.id     //     });      The problem is when I put more one flexslider Shortcode in the same post the localized variable slider.id get the last flexslider Shortcode uniqid , so the last flexslider Shortcode is only that works ,how i can pass all flexslider Shortcode `uniqid` not just the last one?


title: Hide a menu on posts

text: Is it possible to not have a menu on post pages. I think it would be something like "if page show menu, if post don't show menu" but I'm not sure how to put that into PHP. Thanks


title: Understanding the theme details in style.css

text: I'm developing a theme for a friend, and I'm not sure what to put for the author, author uri, etc. Here is the Twenty Ten code:               /*     Theme Name: Twenty Ten     Theme URI: http://wordpress.org/     Description: The 2010 default theme for WordPress.     Author: wordpressdotorg     Author URI: http://wordpress.org/     Version: 1.0     Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)          License:     License URI:          General comments (optional).     */        * For Author, is that the blog owner, or the theme creator?   * Author URI, is that the blog owner's personal website, or the creator's?   * License & License URI, these are not open source. How do I specify that?


title: WordPress Role Capability Restriction

text: I am working on a travelling site and planning to add following feature to the portal.   1. User Registration capability.   2. Let user manage there profile   3. Let user submit there travel story for approval.   4. Let them edit/modify their posts   5. Provide some other theme/color to the user in dashboard. I have already gone through WordPress Roles_and_Capabilities and seems like it will be able to do most of the work for me. Additionally it seems that `Contributor` role will help me to achieve all of the above mentioned goals except mentioned at level 5. I tested `Contributor` role, but finding one issue with it, logged in user able to see all posts in dashboard (Though can not modify them except his/her own). I only want to show current user the posts he has submitted if he/she has been assigned Role as `Contributor`. I am aware that i can use `remove_cap('capability to remove')` and `add_cap('');` mehods to remove/add capabilities. Is there any way to `extend` the `Contributor` role and add capability to show only user created posts. Additionally is it possible to change dashboard theme for all users who have role below `admin` or `editor`? as a side note, I am not developing any plugin.


title: Import a very old WordPress Version into new WordPress

text: Here is my problem: I have been blogging for about six years now at Blogsome.com. I've had no problems with it whatsoever, until a few days ago, when they suddenly announced that they were going to close down on a very short notice. So at the moment I'm looking for a new blog. At the moment I'm thinking of going for a cheap hosted server. My problem is that I want to import all my old posts in the latest version of WordPress. This is problematic because:   * The SQL dump I got out of their backup page is really big (about   30MB). Will this safely import into a new WordPress site?   * Blogsome never updated their WordPress version, so it has been stuck at WordPress Version 1.5.1 for more than half a decade now. How can this SQL dump be safely imported into a new version of WordPress? It's unfortunately the only way I managed to export my blog's database. Blogsome does offer a WRX-file backup option, but that one unfortunately is broken. So what would be the smartest way to handle this?


title: Stylizing Threaded/Nested Comments

text: I'm creating my own theme to WordPress. I got problem with nested comments. I don't wanna limit the levels to reply, but I would like them to stay in that format: ![Levels](http://i.stack.imgur.com/OlXPy.png) This is the code I'm using:               <ol class="commentlist">     <?php wp_list_comments('avatar_size=48'); ?>     </ol>      How can I style the class "commentlist"?


title: using admin functions on frontend

text: I'm updating my plugin to rely on internal functions of WordPress. I'm about to use `wp_generate_attachment_metadata`, but this function seems to be only available in the admin section. Is there an easy was to enable it on the frontend as well?


title: How to differentiate the homepage structure from the category page structure in WordPress template?

text: I am very news in WordPress world and I am finding some difficulties with creation of a personal template. I want implement a blog like this one (that is using WordPress): http://viralpatel.net/blogs/ My blog have to be simplest and there must be only two columns: one for the last posts and one for the most visited posts. I started from an existing template (named Coogee) and have divided the content area (the index.php file) into two columns: the first one shows the new posts and the second one shows the most read posts. I have implement this features with some lines of code that I have put in my columns as show here: http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/how-to-display- most-viewed-posts-in-wordpress-without-a-plugin/ Ok, now the homepage look good for my intents but I am having some problem in the categories page. For example if you click on the "generic" link on Category menu in the side bar you obtain this page: http://scorejava.com/wordpress351/?cat=2 In theory this page should show ONLY the articles that have the "generic" category but this is not true. In fact, in the left column are correctly showed the articles having "generic" category but in the right column still remain the last 5 posted articles... And now I have a question...seems that WordPress use this `index.php` file as template of the content area of all page (except the one that displays a single article that uses `single.php` file) This is not good for me because I want that a category page show only one big column with the last articles of the current category, as here: http://viralpatel.net/blogs/category/spring/spring3-mvc-framework/ As you can see in this blog there is more columns in the homepage but only one column for the category page Is there a way to define an other structure (different from the index.php file used for the homepage articles content) for the categories page? If I can't use an other structure for the categories page and consequently I have to use the same `index.php` file also per the categories content page....there is a way to show the second column only if the visitor is in the homepage and don't show it if he is in a category page (do not show it if the visitor is in a pge like: http://scorejava.com/wordpress351/?cat=2


title: Inserting shortcode is blanking excerpt - any ideas?

text:
I wrapped a shortcode around my post content and I have noticed it is making the excerpt blank on archive pages instead of auto generating one from the_content/post. At a loss as to what is causing it or what to try. Its not even outputting the shortcode in `the_excerpt` its just blank. I would have thought if there was going to be a problem it would have been the shortcode appearing as part of `the_excerpt` but its just blank full stop. All my predefined shortcode does is wrap some complex HTML5 tags around the content which an author would make mistakes doing on a regular basis for consistency in certain situations so its not a complex shortcode. My post is outputting perfectly with `the_content`. As soon as I remove the shortcode it works again. If I put the shortcodes back in and set a manual excerpt it works so its only when it has to auto generate `the_excerpt` from a post wrapped in this shortcode. Appreciate any ideas if anyone else has experienced something similar as I am at a loss to explain it or how to resolve. Many thanks. In simple/stripped back terms im wrapping for example this:               add_shortcode( 'ARTICLE_SECTION', 'trg_shortcode_article_section');     function trg_shortcode_article_section_run( $content ) {       global $shortcode_tags;            // Backup current registered shortcodes and clear them all out       $orig_shortcode_tags = $shortcode_tags;       remove_all_shortcodes();            add_shortcode( 'ARTICLE_SECTION', 'trg_shortcode_article_section' );            // Do the shortcode (only the one above is registered)       $content = do_shortcode( $content );            // Put the original shortcodes back       $shortcode_tags = $orig_shortcode_tags;            return $content;     }     // actual shortcode function     function trg_shortcode_article_section( $atts, $content = null ) {              $atts = array();              $output = '
';         $output .= $content . '
';         return $output;     }     add_filter( 'the_content', 'trg_shortcode_article_section_run', 7 );      In partial loop:
<?=trg_excerpt_article()?>
      Ive put in to debug early right at start before anything else just:               function trg_excerpt_article(){       echo '';     }      That returns blank as well.


title: Users with custom roles not showing in post author select box

text: I am using a function to create new user roles and delete some defaults. However, they are not showing up in the post author box! Only the admin shows up because they are selected as an admin. Any user with a custom role does not show up. Any idea why this would be happening? Here is my function:               // Add New User Roles     function add_new_roles() {              // New Roles To Be Added         $new_roles = array(             array(                 'role'      => 'senior_pastor',                 'display'   => 'Senior Pastor'             ),             array(                 'role'      => 'exec_pastor',                 'display'   => 'Executive Pastor'             ),             array(                 'role'      => 'assoc_pastor',                 'display'   => 'Associate Pastor'             ),             array(                 'role'      => 'elder',                 'display'   => 'Elder'             ),             array(                 'role'      => 'ministry_leader',                 'display'   => 'Ministry Leader'             )         );              foreach($new_roles as $role){             add_role($role['role'], $role['display'], array(                 'edit_published_posts' => true,                 'upload_files' => true,                 'create_product' => true,                 'publish_posts' => true,                 'delete_published_posts' => true,                 'edit_posts' => true,                 'delete_posts' => true,                 'read' => true             ));         }              // Old Roles To Be Removed         $old_roles = array(             'subscriber',             'contributor',             'author'             'editor'         );              foreach($old_roles as $role){             remove_role( $role );         }     }     add_action('after_switch_theme', 'add_new_roles');


title: How include the "text/visual" tabs in your own wp_editor instance?

text: I've made some meta boxes which use the `wp_editor` to create the textareas. When someone is on _any_ page in the admin interface and moves from "visual" tab to "text" tab, all my wp_editor boxes show only a textarea and have no toolbar. Also, when someone switches to "text", it means I can no longer call the `getContent` function (it throws an error). How can I detect this and call a different thing to get the value?


title: How to use "menu_order" field for posts?

text: I have a special case where I'd like to order posts in a custom order and it would be great to use the "menu_order" field that is normally only used for pages. What would be the best way to expose that in the WordPress admin UI?


title: How to setup a permalink structure for a custom post type

text: I would like to know the correct way to setup the permalink structure for a custom post type. Is there any attribute I am to set when I run a register_post_type() ? e.g.               custom post type: product     expected permalink structure: /product/<slug>


title: Creating a nav menu

text: I am not very familiar with WordPress so my knowledge with this is limited. I am working on a travel website where I need to show navigation menu and I am not sure how I can achieve the desired behavior. Here is my case: I need to show destination based drop-down menu and another as category based. Like               Destinations       -Delhi           -Destination1           -Destination2           -More Destinations       -Mumbai            -Destination1           -Destination2           -More Destinations        More      For categories I need to show them as               Category       -Adventure       -Hills       -Romantic       -More      For category part I can create a parent category with child categories and can assign categories to posts as applicable but now sure how to achieve hierarchical menu structure for destination part. Is there anything like hierarchical tags in Wordpress or what are the possible ways to achieve this? Thanks in advance


title: Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error

text: Here we have a snippet from a functions.php file...               add_action('init', 'create_recipes');     function create_recipes() {        $recipes_args = array(            ...some properies...,            'hierarchical' => false,            'rewrite' => array('slug' => 'recipes')            ...maybe more properties...        }        register_post_type('recipes',$recipes_args);     }          add_action( 'init', 'recipes_rewrites_init' );     function recipes_rewrites_init(){         global $wp_rewrite;         $gallery_structure = 'recipes/%post_id%/%recipe%';         $wp_rewrite->add_rewrite_tag("%recipe%", '([^/]+)', "recipe=");         $wp_rewrite->add_permastruct('recipe', $gallery_structure, false);     }      This registers a custom post type 'recipes' and sets up the permalink structure so that we can achieve, for example:               (1) example.com/recipes/394/lunch/      On the 'lunch' page I'll extol the virtues of a good lunch. So far, so good. However, what if I want to sub-categorise 'lunch' into 'sandwich', 'burger', 'salad' (e.g. on the 'sandwich' page I will talk about lunch - specifically sandwiches). First I create these extra pages under the 'recipe' custom post type section, and choose the 'lunch' page as their parent. Now I _might hope/presume_ the following will work, for example:               (2) example.com/recipes/513/lunch/sandwich/      Oh dear, this does not work as _presumed_ \- we receive a 404 error. Ok, how do we get to the 'sandwich' page? Let's see...               (3) example.com/recipes/513/sandwich/      Great, that works - but I wanted the 'sandwich' page parent slug ('lunch') to precede it in the URL ( **see (2)** ). How to solve this? Let's start somewhere... **Step 1** What I do know is that if I change `'hierarchical' => false` to `'hierarchical' => true` then the `the_permalink()` function will (as is desired) construct the permalink as in (2). Great, but this will result in a 404 error with **(2)**. I'm guessing I've either made a mistake in the `create_recipes` function, or perhaps I haven't done enough in the `recipes_rewrites_init` function. **Step 2** I suppose I could (in theory) hook into the WP permalink functionality to intercept the request/permalink, retrieve the post's parent slug (if it has one), and drop it in just before the post's slug. However, that presumably only modifies the resulting permalink, which I've already done in Step 1. What I really need is to ensure the request is routed correctly. **Questions** How do I go about doing this? Is there a known WP way (i.e. existing functionality/options in the initial custom type setup)? **Other thoughts** I'm also aware that Custom Taxonomies can be used (at least in part) to solve the problem of categorising posts - and that there exists a plugin(s) to help. However, I would like to initially stick with Custom Post Types if possible. Thanks. * * * **Update 1** I'm now aware of a plugin called "Posts 2 Posts" which, among other things, enables connections between custom post types - specifically, between different custom post types. However, for my example I am using just one custom post type, and trying to have a natural parent-child hierarchy (which seems like a fairly standard WP thing) rather than forcing a relationship between disparate custom post types. * * * **Update 2** Some further information and a solution of sorts. Here are two important things:   1. Adding custom permalink structures to custom post types can be **_tricky_**.   2. Adding custom permalink structures to custom post types may be **_unnecessary_**. I realised I was fighting Wordpress's excellent out-of-the-box permalink functionality by creating an [unnecessary] custom permalink structure (e.g. `example.com/recipes/513/lunch/sandwich/`) which in retrospect is convoluted; my reasoning was that the post ID should be present in the URL for performance reasons (as opposed to just slugs, which might be slower for WP to match). I imagined this might be possible, but may not be worth the trouble. Instead, I ripped out my custom permalink stuff and just let WP resolve, for example, `example.com/recipes/lunch/sandwich/` \- which now works exactly as expected. Remember to set `'hierarchical' => true`, and the world is your permalink. **Conclusion** If you insist on doing what I was trying to do, it may be possible but will require properly setting up a custom permalink structure to avoid the 404 errors (my original problem). For now I'm going to stick with the standard WP hierarchical permalink functionality.


title: Jetpack: what happens to email subscribers if I access admin on a subdomain?

text: I am currently running my site via http on a url like `domain.com`. In order to continue to make use of CloudFlare's free tier of service, I want to put my admin on a subdomain like `secure.domain.com` and access it over SSL (I would set up `secure.domain.com` to bypass CloudFlare). Having just recovered from a scary episode of losing all of my blog's Jetpack email subscribers as a result of testing this scheme on a test server with a totally different domain name, I am a little nervous about what the effect will be of changing the URL of access to the admin. Does anyone have experience in doing this kind of thing and/or can anyone explain how Jetpack associates email subscribers with a given blog URL and what to expect when changing the URL for the admin to a subdomain?


title: How to add orderby parameter for sorting on category.php

text: I'm on a Category.php page which does the loop like this:               <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>      I usually do a custom loop like this:               <?php //Define the Loop         $temp = $wp_query;         $wp_query= null;         $wp_query = new WP_Query();         $wp_query->query('posts_per_page=2&orderby='.$orderBy.'&paged='.$paged);         ?>      I want to add the orderby variable to the first loop (the one on category.php) but can't figure out how to implement it.


title: Can I call a custom plugin with a direct URL

text: Suppose I have written a `hello world` plugin, the main function is just print out a sting `hello world`. I want to print out `hello world` when I access the URL likes `http://example.com?plugin=helloworld` Is it possible to make the `hello world` plugin functional when I access a specific URL?


title: Login after "Read More" then return to article

text: When a user clicks on an article to "read more" and is then prompted to log in with user name and password, We would like the user to be returned to the article directly instead of being returned to the home page. We are using the soap-authentication plugin: http://matthewkellett.co.uk/portfolio/soap-auth.php Using the redirect_to on the loginform's action doesn't work at all. **Adding code** wp-content/plugins/soap-authentication/soap_auth.php               function login_redirect($redirect_to, $request, $user)     {         $opts = Soap_Auth::getOptions();              //is there a user to check?         if(is_array($user->roles))         {             //check for admins             if(in_array("administrator", $user->roles))                      return home_url("/wp-admin/");             else             {                 return $opts['auth_url'];             }         }     }      replaced else by                       else             {                 if ($redirect_to =='')                 {                     return $opts['auth_url'];                 }                 return $redirect_to;             }


title: Category and Sub category

text: ![wordpress](http://i.stack.imgur.com/Kif5Y.png) There are two main categories such as Job by Education and State wise jobs, if a Job related post is posted how the post can be listed in both the two main categories and sub categories,


title: Perform database function in target URL using jQuery.post

text:
I have a popup which gets the users input (name and email) and sends it to a process.php so I can send an email. I pretty much have that done. But I need to add a functionality wherein it will also the users input to the database (I already have the table for this). My process.php is this:               <?php         $to      = 'myemail@gmail.com';         $subject = 'Join '.$_POST['title'].' Event';         $message = '                                                                     Name: '.$_POST['participant'].'
                 Email Address: '.$_POST['email'].'
                 Message: '.$_POST['message'].'                                       ';         $headers  = 'MIME-Version: 1.0' . "\r\n";         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";         $headers .= 'From: '.$_POST['email']. '\r\n';              mail($to, $subject, $message, $headers);              echo "You have successfully signup up for this event";     ?>      I tried adding this:               global $wpdb;     $table = 'wp_mytable';     $name = $_POST['participant'];     $email = $_POST['email'];     $event = $_POST['title'];          $wpdb->insert(         $table,         array(             'id' => '',             'name' => $name,             'email' => $email,             'event' => $event,         ),         array(             '%d',             '%s',             '%s',             '%s',         )     );      But I get a fatal error. I also tried adding `require_once(../wp-load.php)` But still no good. Thanks in advance!


title: Ajax call activate after submit in edit-tags.php page

text: Is there a proper way to activate a ajax call in wordpress in the edit category page after the submit is pressed?


title: Problem with quotes

text: I have a strange problem with the latest version of Wordpress: Some writers, when they write a story, you see the quote character `'`, replaced with `/`, something that does not happen to me. Is there any special settings in the CMS that could cause this annoying problem?


title: Can I protect a type of content site-wide with a single password?

text: I am developing a theme for a client who has a catalog of products. Each product has a spec sheet that he wants to make available to logged-in users. It's not a real security issue, just a means to simplify the page for casual visitors. Right now he emails clients a password and keeps track of logins based on which password he gave out. He'd like to continue doing that. So I'd like to come up with a way of:   * logging a user in with a single field   * using `is_user_logged_in()` and related inquiries to check whether to display links to the protected content   * denying such visitors access to the Admin side completely Is this out of the scope of WP user roles? If not, any suggestions on how I could achieve this?


title: Open wordpress media library in 3.9.1 version

text: I can not speak English....I hope you understand my question. I have this code that opens the media library, but it only works in wordpress 3.6.1 and lower version               <script>     var file_frame;           // "mca_tray_button" is the ID of my button that opens the Media window      jQuery('#mca_tray_button').live('click', function( event ){          event.preventDefault();            if ( file_frame ) {           file_frame.open();            return;        }             file_frame = wp.media.frames.file_frame =   wp.media({            title: jQuery( this ).data( 'uploader_title' ),            button: {                text: jQuery( this ).data(  'uploader_button_text' ),            },            multiple: false          });             file_frame.on( 'select', function() {              attachment =        file_frame.state().get('selection').first().toJSON( );              // "mca_features_tray" is the ID of my text. field that will receive the image            // I'm getting the ID rather than the URL:                jQuery("#mca_features_tray").val(attachment.id);                 // but you could get the URL instead by doing something like this:               jQuery("#mca_features_tray").val(attachment.sizes.thumbnail.url);                 // and you can change "thumbnail" to get other image sizes              });             file_frame.open();             });      </script>          <button id="mca_tray_button">Open Media</button>      Now I want a code (for 3.9.1 version) that opens media library and user can select a file then return the file's url in a input.


title: Check and dequeue if multiple stylesheets exists using wp_style_is?

text: I need to dequeue styes for 3 plugins that load the same font stylesheet so i come up with the following function that of course not working:               add_action('wp_enqueue_scripts', 'dequeue_by_handles', 999);     function dequeue_by_handles() {         $handle = array(             'fontawesome',             'font-awesome',             'font-awesome-style'             );              if( wp_style_is( $handle, $list = 'enqueued' ) ) {             wp_dequeue_style( $handle );         }     }      Please note that firstly I need to check if a stylesheet handle exist then dequeue it. Thank you.


title: Is it possible to make grandchild themes?

text: If I use one of the popular frameworks such as Genesis, is it possible to create grandchild themes? As an example, I want to use Genesis as the backbone of all my sites. Genesis is called a framework but is actually a parent theme. Then I select one of the Genesis child themes for sale at StudioPress, and want to continue customising it for each of my sites. Would I be creating a grandchild theme for all of my sites, and how would I go about it?


title: get the post thumbnail returns the full size

text: The function `get_the_post_thumbnail($post->ID, 'thumbnail');` not always returns the thumb size of the image (which is 100x100) for some posts it does but for most of them it doesn't. Even though the actual file exists (say for image `myImg.jpg` there is a thumb image under the name `myImg-100x100.jpg`) but still the function returns the full size. any thought on troubleshooting this? Update, I just noticed that the images that are returning the full size are named in Arabic characters, could this cause the issue?


title: Custom Post Type link not showing content

text: I have created 2 custom post types. One called artist and one called work. When I create a post in artist and view it the link is fine and I can view the content. However in work when I add a new post and go to view it it says that it cannot find the content and the page is missing. Here is my functions.php code.               add_action( 'init', 'create_post_type' );     function create_post_type() {     register_post_type( 'artist',         array(             'labels' => array(                 'name' => __( 'Talent' ),                 'singular_name' => __( 'talent' )             ),         'public' => true,         'has_archive' => true,         'supports' => array( 'thumbnail' ),         'supports' => array('thumbnail', 'title', 'editor'),         'rewrite' => array('slug' => 'talent'),              )     );          register_post_type( 'work',         array(             'labels' => array(                 'name' => __( 'Content' ),                 'singular_name' => __( 'content' )             ),         'public' => true,         'has_archive' => true,         'supports' => array( 'thumbnail' ),         'supports' => array('thumbnail', 'title', 'editor'),         'rewrite' => array('slug' => 'content'),              )     );     }


title: Do I need to resize an image to fit the post?

text: I'm going to post an image in a blog post, first uploading the image to my server, and using its url. If the image is bigger than the maximum width of my blog-post, will it take longer to download, or will WordPress squish the image for the space it has to fit? If I need to make the image the right size to fit, what size? My blog is at http://wordfruit.com/blog Thanks,


title: How can I highlight admin comments?

text: Basically what I want is to have all comments posted by admins with different background color than the rest, so they're easily distinguishable. I wasn't able to find any plugin that would do this though, and hacking it into the theme doesn't look very clean. Any suggestions?


title: Several loops in sidebar issues

text:
I've created sidebar tabs that display the most recent, popular and random posts. In other words I'm creating several loops in my sidebar. This seems to cause some problems, though. Do I have to reset something or just use a complete different code overall? The code for the sidebar tabs looks like this:

 Popular

Recent

Random

          <?php     $pc = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>          <?php while ($pc->have_posts()) : $pc->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

     <?php     $rp = new WP_Query('orderby=date&posts_per_page=5'); ?>          <?php while ($rp->have_posts()) : $rp->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

     <?php     $ranp = new WP_Query('orderby=rand&posts_per_page=5'); ?>          <?php while ($ranp->have_posts()) : $ranp->the_post(); ?>
     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?>     <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>  <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
Posted on <?php the_time('F jS, Y') ?>
     <?php echo excerpt(8); ?>

          <?php endwhile; ?>     <?php wp_reset_query(); ?>

      The current issue is that the first tab "Popular" displays 5 posts as it should, but the other 2 tabs display 6 posts, although I've clearly coded it so that only 5 should be displayed!!!! My website is here for reference (if you use IE - and I hope you don't - please don't be shocked that apart from the tab above none other is working - there are a lot of issues in IE suddenly (since yesterday) possibly caused by CSS, maybe some HTML error - am working on it currently). Thanks a lot in advance!


title: BBCode & BBPress 2.0?

text: I've been trying to get bbcode working in BBPress content, using various plugins. I'm running WP (3.2.1), BuddyPress Plugin (1.2.10) and BBPress 2.0-rc-5. I've got bbcode working in wp posts and comments via some modifications of this plugin http://wordpress.org/extend/plugins/bbcomments/ All I've done is add a few more add_action lines:               add_action('the_content', 'render_comment', 1);     add_action('the_content', 'render_comment_code', -1);      Though making the BB code work inside BBPress topics and replies is proving tricky, I've tried adding:               add_action('bbp-reply-content', 'render_comment', 1);     add_action('bbp-reply-content', 'render_comment_code', -1);     add_action('bbp_topic_content', 'render_comment', 1);     add_action('bbp_topic_content', 'render_comment_code', -1);      But no dice. I also tried calling the plugin function and the actions inside bbp-common-functions.php. My PHP knowledge is pretty limited, so any advice on where to look next would be appredciated.


title: Public posts - preventing duplicate form submissions

text: I'm creating a public form on a page that allows non-registered (public) visitors to create posts of a custom post type. I'm using nonces, which I naiveley thought would expire once they were used. This doesn't appear to be the case. This post seems to address the issue by creating a meta field and verifying that it doesn't exist before creating the post. Is there a best practice that prevents double-form submissions (that doesn't require writing a meta field?) T


title: Add option to "Gallery Settings" section

text: I want to add a option to the "Gallery settings" (when you insert a gallery into a post). I once found some code on how to do this, but unfortunately I can't find it anymore. I can't even remenber if it was a hook, but I think it was some hackish stuff ;-) Thx


title: How safe / sanitized is wp_insert_posts()?

text: Looking at the Codex for wp_insert_post() it states that this function "...sanitizes variables, does some checks, fills in missing variables like date/time, etc. " (EDIT: I updated the Codex entry to include a more robust example that includes security as well as post meta and category assignment) Just wondering whether I need to do any further sanitization to prevent XSS hacks and the like or whether enough is being done through the function. To be honest, I've checked through the function in core and haven't found any wp_kses() or other sanitization on post_content for example, so I'm a little concerned. All I can see that it does is stripslashes_deep() on the data. So should I be running wp_kses() or anything else when I build my arguments to wp_insert_post()? What's the best practice here? The Codex is pretty cavalier about security in its example. Thanks


title: Adding function directly vs using hook in function.php

text: We can use functions like `register_nav_menu()` directly in `function.php` and it works and we can also use a function to put `register_nav_menu()` inside of it and attach that function using a `hook` like init and it works as well. Why do we need to use a `hook` in that particular situation?


title: Custom Post Type title not populating

text:
I am attempting to get the title displayed for a function. I am sending myself an email to see if I can get this to work for different titles. Currently the only way I can get it to work is via hard coded number inside the get_the_title. my example below works.               $tweetingthing = get_the_title(1067);                 $to      = 'myemail@email.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' .  $tweetingthing . ' page id is   ' . $this_page_id;                   if( wp_mail($to, $subject, $body ) ) {             echo('
Message successfully sent!
');         } else {             echo('
Message delivery failed...
');         }      I obviously want more than just that one title, I'd like each title to be sent via email. I have tried this:               global $post;     //$thePostID = $post->ID;     $wp_query->post;     $this_page_id = $post->ID;     echo $this_page_id ;     $tweetingthing = get_the_title($this_page_id);              $to      = 'mh@gmail.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' . $tweetingthing . ' Post id is   ' . $this_page_id;                   if( wp_mail($to, $subject, $body ) ) {             echo('
Message successfully sent!
');         } else {             echo('
Message delivery failed...
');         }      This provides null for $tweetingthing and $this_page_id (I know it's a post id I'm trying to get I simply used the variable giving in the example hope that doesn't confuse anyone). I also tried               $tweetingthing = get_the_title($post_id);      also tried $tweet_post_id = the_ID(); $tweetingthing = get_the_title($tweet_post_id); no luck               $page_object = get_queried_object();     $tweetingthing = get_queried_object_id();      results in a post title of 0 Addition info: I'm using a status transition action to make the function fire. When it goes to publish and matches the custom post type it performs. I'm using a custom post type How can I get Custom Post Title? full source code :               function intercept_all_status_changes( $new_status, $old_status, $post ) {      if ( $new_status == 'publish' && get_post_type( $post ) == 'tweet' ) {          // Post status changed          twitter_run_when_published ();      }     }       add_action( 'transition_post_status', 'intercept_all_status_changes', 10, 3 );               function twitter_run_when_published () {     //     //email the stuffuff     //           global $post;      global $wp_query;      //$thePostID = $post->ID;      $wp_query->post;      $this_page_id = $post->ID;      echo $this_page_id ;              $to      = 'meanderingmonarch@gmail.com';         $subject = 'Hi!';         $body    =  'Hi,' . chr(10) . chr(10) . 'Hi title= ' . $tweetingthing . ' Post id is   ' . $this_page_id;                    if( wp_mail($to, $subject, $body ) ) {              echo('
Message successfully sent!
');          } else {              echo('
Message delivery failed...
');          }     }      So after @nickyoung mentioned this was weird I thought I'd try a if status changes at all send an email. It sent me 4 messages. The first: title was not there (post status not there) The second: title was not their (post status not there) The third: title WAS there (and post status was draft) The fourth: no title and post status was not there edit: just cleaned up some jibberish sentences edit2: Added full source code to see if anything may help edit3: Added extra info about post status transitions


title: How to assign the default file at "Appearance > Editor"?

text: My theme has a custom.css file that I use to allow designer's to customize the it to their liking. However, when clicking on "Appearance > Editor", the style.css file is loaded there by default. Since I don't want custom edits done on this file, I'd like to minimize the chances that someone edits it by placing custom.css there instead. Is this possible? Perhaps with the shiny new 3.2 codebase?


title: Showing all post from all post type in admin backstage

text: I try to create an admin page where to display all posts from all custom post type. It is something like in edit.php, but instead of displaying single post type,I would like to display all posts in one page from multiple custom post type. I follow the tutorial at here to create the table. Everything is fine, but there is somethings that I can't solve. Actually the problem mostly in php rather than WP itself. Here is where I trying to do : query the posts from the desired custom post types,and from the object return store it in array for further use. Here is my codes :               function getallposts() {         global $current_user; // i need to show the posts depends on the user id.         get_currentuserinfo();                    if(!current_user_can('administrator') && current_user_can('edit_posts') ) {              $userid = $current_user->ID;              } elseif(current_user_can('administrator')) {$userid='1';} // administrator can view all the posts, but the users only view their own posts             $args = array(        'numberposts'     => -1,        'offset'          => 0,        'orderby'         => 'post_date',        'order'           => 'DESC',        'post_type'       => array('cpt1','cpt2'),//post types that i need to query        'author'          => $userid,//this is refer by the user login info above        'post_status'     => 'publish' );         $myposts = get_posts( $args );//here using get_posts to query the post.              $myitems =array();//declare the the array.         foreach ($myposts as $post) {         $metavalue = get_post_meta($post->ID, 'rating', true);//get the meta value for the post              $myitems =array (         'post_title' => $post->post_title,         'ID'=>$post->ID,          'post_author'=> $post->post_author,         'post_date' => $post->post_date,         'rating' =>$metavalue         ); // i want to store it in an array for further use.don't know if I am doing right.          }return $myitems;//here is i don't get the idea to return the array from $myitems above}      If the code above is too complicated, in a nutshell here is what I trying to do:               function getallposts { //get the posts query in a function               $args = array ();                $allpost = get_posts($args);//here is to get the posts by argument form $args             foreach ($allpost as $post){              $post_title = $post->post_title...               .....  //define some of the  object that needed for further use.              $value = array($post_title.....);//the defined object is store in an array for further use.             }                  return $value //return the value//here is I don't know how to return the value.          }      My intention is to sort the $value in this way:               $example_data = array(       array('ID' => 1,'booktitle' => 'Quarter Share', 'author' => 'Nathan Lowell',         'isbn' => '978-0982514542'),       array('ID' => 2, 'booktitle' => '7th Son: Descent','author' => 'J. C. Hutchins',         'isbn' => '0312384378'),       array('ID' => 3, 'booktitle' => 'Shadowmagic', 'author' => 'John Lenahan',         'isbn' => '978-1905548927'),       array('ID' => 4, 'booktitle' => 'The Crown Conspiracy', 'author' => 'Michael J. Sullivan',         'isbn' => '978-0979621130'),       array('ID' => 5, 'booktitle'     => 'Max Quick: The Pocket and the Pendant', 'author'    => 'Mark Jeffrey',         'isbn' => '978-0061988929'),       array('ID' => 6, 'booktitle' => 'Jack Wakes Up: A Novel', 'author' => 'Seth Harwood',         'isbn' => '978-0307454355')     );      Thanks


title: How to check if upload window came from the featured image link?

text: I need to verify if the media-upload screen came from a click on the "feature image link" on the admin screen. How can i do it? I've already change the way the uploader works , but I need to check this because there is a special flow for the featured image upload.


title: Translate custom taxonomy terms

text: I got one problem about translating taxonomy terms. Situation: I have multisite instalation with many sites in different languages. I am using broadcast plugin that broadcast some post types and taxonomies through all sites from main site. I use poedit to translate strings in that different sites for different languages. Problem is that every time I sync taxonomies they refresh to default name. Is it possible to translate broadcasted taxonomy terms in poedit with .po and .mo file on particular site. When I sync data terms I use same taxonomy but different label on diffrent site. Thank you very much, Best regards!


title: Custom Taxonomy tree view not showing correctly in backend

text: I'm using a Custom Post Type **product** with the Custom Taxonomy **product_category**. When editing a product in WordPress, there is a problem with displaying the product categories tree view right. When an item is checked, it will move to the top of the list. When this item is a top level category, the child categories stay in the same spot in the list and therefore aren't shown correctly. When an subcategory is selected, it will also move to the top of the list. It isn't shown in the tree view anymore. An example:               Before selecting:     O - A     O   - A.1     O   - A.2     O   - A.3     O - B     O   - B.1     O   - B.2     O   - B.3          After selecting:     X - A.2     X - B     O - A     O   - A.1     O   - A.3     O - B.1     O - B.2     O - B.3          O = unchecked     X = checked      I thinks it's a WordPress bug but I can't find the problem in the WordPress core files. Does anyone know a solution?


title: Use reserved subdirectory for multisite

text: Whenever we try to go to domain.com/blog, we are redirected to primary- domain.com. How can I set it so that domain.com/blog stays its page. Our setup is a WordPress multisite install with subdirectories. We have sites which use multiple domains. Our primary site is at primary-domain.com, which is not viewable by anyone outside of our intranet. For example our sites include primary-domain.com/ <\--not viewable by public.   domain.com/subdirectory <\--works   different-domain.com/different-subdirectory <\--works   domain.com/blog <\--redirects to primary-domain.com   I've already filtered "blog" from the reserved subdirectory and tried filtering permalinks and rewrite rules. I've also tried going into the database to remove references to "blog/" in the permalink fields and the rewrite fields in the wp_1_options table. I've also tried various methods to remove the "blog" slug from the main site but the domain.com/blog site always redirects to primary-domain.com. At this point if someone can just point me in the correct direction, it would be a big help.


title: Best function/method to access wp-config?

text: I have a developer who is accessing the wp-config file directly to get database information. I would think that WP has a better way to do this. What do you think community?


title: How do I get the top-level terms in a custom taxonomy?

text: I have a custom hierarchical taxonomy setup for a conference website. The top- level terms in this taxonomy are Dates, which have child terms representing session slots on that date. I'm trying to figure out how to get a list of the top-level terms within the taxonomy, that is I only want the terms that are Dates, not the terms that are sessions. Is this possible using `get_terms()`?


title: Creating custom shortcode

text: I'm trying to create some custom shortcode - I want to be able to have names and numbers of people I want to display on my website, but as a shortcode, so it doesn't have to be typed in again and again. So for instance to have [joe] relate to 'Joe Bloggs - 01925 265646' I'm currently using the Ultimate Tables plugin and would want to put the shortcode into this, and then for it to come up with the longer information. I've been playing around for a few hours and still struggling - I've tried putting it directly into functions.php and have tried using the 'Shortcodes Pro' plugin but I can't figure out how to make it work (sorry, I'm not a massively advanced Wordpress user!). This is the code I put into the functions.php section of the theme:               // Add Shortcode     function joe() {     }     add_shortcode( 'Joe Bloggs - 01925 265646', 'joe' );      Pretty much, my aim is to avoid having to manually enter phone numbers because on our old website this led to the phone numbers being entered incorrectly sometimes, as they are entered about dozens of times. Thanks so much for your help in advance.


title: Admin moderates ALL comments (including post author)

text: I have comments enabled on my custom post type page, which works well but I need the admin to moderate all comments before they are published. At the moment the post author whose level is 'contributor' is able to post comments without being moderated. I can't find any way to do this currently, nor can I find any plugins. Any help would be much appreciated!


title: Changing the header image using WPML

text: I've got an issue with changing a header image based on language and the file path to the image. Have tried relative and absolute paths but still end up with a broken/missing file icon. In my functions I have:               function header_image_switcher() {         switch( ICL_LANGUAGE_CODE ) {                  case 'en':                 $link_to_image = '/images/top-header-en.png';                 break;                  case 'fi':                 $link_to_image = '/images/top-header-fi.png';                 break;                  case 'sv':                 $link_to_image = '/images/top-header-sv.png';                 break;                  return $link_to_image;         }     }      and the template contains               echo "<img src=" . header_image_switcher() . " />";      My images folder is outside of the theme and in the same folder as my install but the images still won't load. Any obvious mistakes I'm making?


title: Show last 5 posts from specific category

text:
I'm trying to show the last 5 posts from a specific category, which will be linked to a function so i can insert the shortcode in a Wordpress page. The code i have is as below, it does everything i need (although i want to add featured image too) except it does not show posts from a specific category. I've tried numerous things, but cannot find a working fix.               function Last5posts()     {     $args = array( "showposts" => 5, "category" => 3 );                       query_posts($args);          $content = "";          if( have_posts() ) :               while( have_posts() ) :                  the_post();             $link = get_permalink();             $title = get_the_title();             $date = get_the_date();                                                $content .= "
";             $content .= "
$title / $datehave_posts()) : $catquery->the_post();       Any help would be greatly appreciated.


title: Display custom post data in sidebar w/ dropdown

text: I'm trying to set up a sidebar area that'll do two things:   1. Display a drop-down of posts in a given custom post types.   2. Display post metadata (content and custom fields) if selected post The thing that's getting me is two-fold:   1. Having the selected post metadata display in the sidebar once selected via the dropdown   2. Having the content refresh via ajax or jquery so it doesn't refresh the entire page


title: Is there any way to draft a revision of a published page or post? What workarounds have you used?

text: Say I've already published a page or post. I now want to make changes, but I want a colleague to check them over before they go live. Is there any way of doing this? **Edit: I do realise this isn't currently possible as such and it's creative workarounds I'm interested in.** On the site I'm currently working on, I also have a separate password protected 'staging' site for drafting major content changes/additions, and once approved I copy and paste to the live site. I'm wondering if anyone's used a similar method, but perhaps automated the 'push' to the live site? I'm aware of this question: Database synchronization between dev/staging and production, but that's more about wholesale synchonization of entire databases rather than individual pages or posts. **Now offering a bounty in order to try and drive out some additional ideas for workarounds.**


title: I want to take out reviews tab from single product page?

text: I want to take out the reviews tab from single product page in woocommerce. I mean i want to display reviews tab below the product description tab in single product page. Please help me out.