title: Dynamically creating multiple widgets from Mustache templates

text: I built a bunch of basic Mustache templates for a project, and now I'm wanting to effectively make them available to WordPress as widgets.               //This uses Composer to manage dependencies (Mustache).     require 'vendor/autoload.php';          $mustaches = array_diff(scandir(dirname(__FILE__) . '/templates'), array('..', '.'));     $templates = array();     foreach ($mustaches as $mustache) {       $code = file_get_contents(dirname(__FILE__) . '/templates/' . $mustache);       $templates[$mustache] = array(         'id' => str_replace('.mustache', '', $mustache),         'template' => $code,         'name' => preg_replace('/\{\{\! name\: \"(.*?)\"\}\}/', '$1' , explode("\n", $code, 1)), //Human name defined in comment at start of template.       );     }      Now what do I do? I can't dynamically define classes like so:               foreach ($mustaches as $mustache) {           class $mustache extends WP_Widget { ...       This gives a syntax error because dynamic extension isn't really a thing anyone does. **How do I register multiple widgets with a single class definition?** Thank you!


title: Custom Class to wp nav menu

text: I am trying to edit the default arguments in the wp_nav_menu function. Basically I need to add a custom class to the UL and a custom class to the LI. I have tried to use               <?php     function my_wp_nav_menu_args( $args = '' )     {         $args['menu_class'] = "test";         return $args;     } // function          add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );     ?>      This added a test to the div outside.I tried to edit 'items_wrap' => '%3$s', no luck.


title: Disable WP notifications for commenting on own posts

text: How/where can I disable WP email notifications for commenting on own posts? I want to do this globally for all users on the site, not only per-user through WP admin. Are there any hooks which I can use to cancel these emails? Thanks!


title: How to know what are the style sheets are available in wordpess?

text: I just like to use jquery-ui Style Sheet but i don't know whether it's pre- installed in WordPress or not b'coz without knowing that i think it will create a problem. what in case it is available in wordpress at that case `wp_register_style()` will become waste because first we have to `wp_deregister_style( $handle )` and then register our script otherwise it may conflict. even if i'm asking a wrong question just give me some idea or resources where i can find available scripts and styles,so that i can easily find out what are the styles and script i need to register and enqueue in my plugin.One more thing i don't have to do useless code like register if it is already available. Thanks


title: Upgrade to 3.6.1; Cannot change the links in the page anymore

text: After I upgraded to this version I cannot seem to save the page anymore when there are links in the page to other pages on the website. If I delete the link I am able to save the page. > The connection to the server was reset while the page was loading. > > The site could be temporarily unavailable or too busy. Try again in a few > moments. If you are unable to load any pages, check your computer's network > connection. If your computer or network is protected by a firewall or proxy, > make sure that Firefox is permitted to access the Web.


title: Trying to apply apply_filters to custom post type content - not working

text: this is kind of a strange request. I have a plugin that adds a custom post type - then the plugin has some settings where the user can select from any of the posts they created (in that custom post type) to add to another posts content. The code is below - It outputs the custom post content underneath the main posts content as it should, however it doesn't apply the filters - so for instance, if the user puts in a youtube link in to the custom post type content, is shoots out the link rather than apply the filter and embed the video. Any ideas would be much appreciated, been banging my head around this for a while. Thanks!               <?php     global $wpdb;      $options = get_option('wp_optin_studio');     $post_form = $options['post_form_select'];     $post_options = get_post_meta($post_form, 'wp_optin_form_settings', true);          $optin_post = get_post($post_form);     $optin_content = $optin_post->post_content;     $optin_content = apply_filters('the_content', $optin_content);     $optin_content = str_replace(']]>', ']]>', $optin_content);               /* ADD CUSTOM POSTS TO POSTS */     function wp_optin_studio_add_post_forms($content) {         global $options;          global $post_options;         global $post_form;         global $optin_content;              $my_custom_text = $post_options['optin_studio_headline']; // text-html to replace         $my_custom_text .= $optin_content;              if(!is_single()) {             return $content;         }         if(is_single()) {             $content .= $my_custom_text;         }         remove_filter( current_filter(), __FUNCTION__ );              return $content;          }          /* CHECK TO SEE IF USER WANTS CUSTOM POSTS ON THE PAGES/POSTS */     if ($post_form) {         add_filter('the_content', 'wp_optin_studio_add_post_forms');     }          ?>


title: How to redirect user to a page after form submission

text: I have three dropdown filters on the front site to select country, territory and region and need to redirect the user to the country/territory/region page depending upon the filter values on click of Submit button. FYI, I have pages with the same slug.eg- example.com/country-name/territory- name/region-name I am trying to use `wp_redirect( $final_url ); exit;` but it is throwing a warning- Warning: Cannot modify header information - headers already sent by (output started at E:\path\to\root-folder\wp-includes\class.wp-styles.php:154) in E:\path\to\root-folder\wp-includes\pluggable.php on line 1121 Please help. Can someone suggest me some some better way? //Edit- here is my code               if(isset($_POST['submit']) and $_POST['action']=='findurl')         {             //Result $POST Array ( [countrySelect] => 1 [territorySelect] => 1 [regionSelect] => 2 )             if (isset($_POST['countrySelect'])){                      $rows_country_url = $wpdb->get_results("select url from country where id=".$_POST['countrySelect']."");             }                  if (isset($_POST['territorySelect'])){                      $rows_territory_url = $wpdb->get_results("select url from territory where id=".$_POST['territorySelect']."");             }                  if (isset($_POST['regionSelect'])){                      $rows_region_url = $wpdb->get_results("select url from region where id=".$_POST['regionSelect']."");             }                       if($rows_country_url[0]->url !=''){             $final_url = home_url('/').$rows_country_url[0]->url;}                  if($rows_territory_url[0]->url !=''){             $final_url = $final_url.'/'.$rows_territory_url[0]->url;}                  if($rows_region_url[0]->url !=''){             $final_url = $final_url.'/'.$rows_region_url[0]->url;}                  echo $final_url;                  if($final_url!=''){              wp_redirect( home_url() ); exit;             echo "not blank";             }else{ echo "Please select values";}         }


title: How Do I Remove Comment Date and/or Comment Date Link

text: Found this code in the WP Codex but not sure how to use it to remove the hyperlink and/or date from comments.               delete_comment_meta( $comment_id, $meta_key, $meta_value );


title: Correct method of redirecting user login

text: The popular membership plugin 's2Member' uses the wp_login action hook to wp_redirect a logged in user to where s2 deems appropriate. This causes a conflict with other plugins, in that other plugins may rely on the WP_User object being returned from the wp_signon function, which will not happen if the user is redirected by the wp_login hook. **What is the correct way to redirect a newly logged in user? I would assume the filter login_redirect, no?** The problem with that is that s2Member uses remove_all_filters on that very same filter... Please keep in mind that while this may seem like a plugin-specific question, my real question is in bold, and applies to WP in general.


title: How to oEmbed from custom field, responsive to container size and responsive

text: I am using Magic Fields 2 to add custom fields/meta boxes. One custom field is for a Vimeo or YouTube video URL to be displayed. The following code oEmbeds the video URL:               <?php if (!((get_post_meta($post->ID, 'video_url', TRUE))=='')) {         echo wp_oembed_get( get_post_meta($post->ID, "video_url", true) );     }?>      To resize the video, I have used added the code inside `<div class="video">` and resized it using CSS - `.video iframe {width:500px;height:312px}`. The problem, this method is not responsive. I have also tried `.video iframe {width:95%;height:95%}`. This outputs looks like - ![enter image description here](http://i.stack.imgur.com/1wZUJ.png) The Fluid Video Embeds plugin seems to do the job for oEmbeds through the normal WordPress method and through shortcode, but not with using a custom field.


title: Single Post Template with Dropdown Option?

text: I'd like users of my theme to be able to select a single post template via a dropdown menu on the post screen. I know of a plugin that achieves this but I would like to be able to achieve the same thing without the plugin. Anybody have a solution?


title: Undefined offset: 2

text: I'm using this function I found from this answer here about showing prev/next navigation for a current page               <?php     $pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");     $pages = array();     foreach ($pagelist as $page) {        $pages[] += $page->ID;     }          $current = array_search($post->ID, $pages);     $prevID = $pages[$current-1];     $nextID = $pages[$current+1];     ?>      and I get an Undefined offset: 2 error with wp-debug set to true. Could anyone help please- sorry I am a bit of a beginner with some of this, but I think it refers to the last 2 lines with $prevID and $nextID. Thanks


title: How to filter multiple queries with search?

text: My theme has two columns, each column has it's own query. When I do a search on my theme, it only filters the main query and not my secondary query that is on my second column. How do I do that?


title: Pagination for normal (standard) posts on a page with a custom loop?

text:
probably a rather straight forward question. my "homepage" is not the blog-page. I have a `page-template` named `page- knowledge.php` which has the following loop on it.               <?php             echo '
';                  $args = array(                 'post_type' => 'post',                 'posts_per_page' => 5,             );                  $loop = new WP_Query( $args );             while ( $loop->have_posts() ) : $loop->the_post();                 global $post;                 get_template_part( 'inc/post', 'item' );             endwhile;                  wp_reset_postdata();             echo '
';         ?>      So, this page queries `5` of the normal posts. How can I add a pagination to this page so I can jump through the rest of the posts just like you would expect it. * * * **UPDATE**               <?php             echo '
';                  $args = array(                 'post_type' => 'post',                 'posts_per_page' => 5,             );                  $loop = new WP_Query( $args );             while ( $loop->have_posts() ) : $loop->the_post();                 global $post;                 get_template_part( 'inc/post', 'item' );             endwhile;                  wp_reset_postdata();             echo '
';         ?>
             <?php                  $endsize = $midsize = 1;                 $type = 'plain';                 $loop->query_vars['paged'] > 1 ? $current = $loop->query_vars['paged'] : $current = 1;                      // Sanitize input argument values                 if ( ! in_array( $type, array( 'plain', 'list', 'array' ) ) ) $type = 'plain';                 $endsize = (int) $endsize;                 $midsize = (int) $midsize;                      // Setup argument array for paginate_links()                 $pagination = array(                     'base'          => @add_query_arg('paged','%#%'),                     'total'         => $loop->max_num_pages,                     'current'       => $current,                     'show_all'      => false,                     'end_size'      => $endsize,                     'mid_size'      => $midsize,                     'type'          => $type,                     'prev_next'     => false,                     'paged'         => $loop->query_vars['paged']                 );                      echo paginate_links( $pagination );             ?>


title: Relative number of post in category

text: For a post x in a category y, how can the following output be achieved:   * Post x is the `n`th out of `m` posts in the category y. where `m` is the total number of posts in the category, and `n` is the number of the current post (ordered by publishing date).


title: Change the "main site" on a wordpress multisite installation

text: I'm trying to install the Wordpress installer so I can import a lot of data from my local development machine onto a site.               WordPress       This importer is not installed. Please install importers from the main site.      Unfortunately site 1 no longer has a proper vhost as it's been discontinued a while ago. I've tried setting site 1 to non-public in the network admin, and changing these wp-config settings:               define('SITE_ID_CURRENT_SITE', 3);     define('BLOG_ID_CURRENT_SITE', 3);      So far this still tries to direct me to the defunct web address. Any other database settings or config settings I can change to move the "main site" to a different number?


title: Is priming a Transient Cache possible?

text: I'm currently using Wordpress Transient Caching when querying images I've uploaded and tagged. Using Transient Caching has really sped up these queries once they are cached, but unfortunately, once the cached query expires it is only cached again when someone loads that page. Is it possible to preload/prime transient caches so users don't get stuck with that responsibility and long wait time? If not, should I be using something else to cache that does have that ability? Thank you in advance for any advice


title: Limit the_excerpt in the first point (.) of the sentence

text: I would like to filter the function `the_excerpt` to stop to find the first endpoint. Ex: "This is the article summary which ends at the endpoint with a full-stop." Any idea is welcome.


title: 3.5 media manager add CSS / JS to new 'tab' iframe content

text:
Whilst (patiently) waiting for proper documentation and/or a few tutorials on the new media uploader I'm still using the `media_upload_tabs`filter to add a tab to the uploader. Here's my (working) code:               <?php          add_filter( 'media_upload_tabs', 'olab_add_media_tab' );     function olab_add_media_tab( $tabs ) {         $tabs['bildarkiv'] = __( 'Bildarkiv', 'bildarkiv' );         return $tabs;     }          add_action( 'media_upload_bildarkiv', 'olab_tab_content' );     function olab_tab_content() {       ?>
WOOT!
       <?php     }          add_action( 'print_media_templates', 'obab_enqueue_admin_stuff' );     function obab_enqueue_admin_stuff() {       wp_register_style( 'bak-css', plugins_url( 'css/main.css', __FILE__ ) );       wp_enqueue_style( 'bak-css' );       wp_enqueue_script( 'bak-js', plugins_url( 'js/app.js', __FILE__ ), 'jquery' );     }      This all works, but the content of the tab is enclosed in an iFrame which means that my enqueued scripts + styles do precisely nothing! I don't mind the iFrame I suppose, but I can't find a way to attach CSS / JS to the `<head>` of the iFrame. Any inline JS is stripped out when the iFrame is rendered. Anyone know about this?


title: Change Twenty twelve theme background color

text: I use the twenty twelve theme and I would like to change the background color manually by modifying the right files in the `plugins` folder. However, I can not find what to change in the style.css file. I even tried to modify the background color through the Wordpress interface to #e50000. After that, I looked for a line containing e50000 in my wordpress directory, but there seems to be none. I can't figure out which line to change in my wordpress directory to change the background color.


title: Category / Custom Post Type permalink issue

text: So I'm currently working on a client site and trying to switch some old posts over to use new custom post types. Prior to this point, her website was set up in such a way that she could add both books with chapters as well as uncategorized advice columns to her site. In order to add either of these items, she would add a new post, and stick them in a specific category. If she wanted the post to show up as a chapter in her book, she filed it under the correct subcategory of the "books" category. If she wanted the post to show up in her advice columns, she would add it to the "advice" category. Permalinks for this site were set up in such a way that when reading an individual chapter of a book, it would look like so "/books/ _the-book/the- chapter_ " Now, I'm trying to recombobulate her set up a bit. Instead of simply adding a new post and categorizing it to achieve this effect, I split out the two different areas into their own custom post types (called _chapter_ and _column_ ). When setting up the new custom post type, I'm trying to set up the rewrite argument to use the same permalink that was used previously, however it appears that even after deleting the category, the permalink is still reserved by the category. What I mean is I receive 404's when trying to access "/books/the-book/the-chapter", but if I change the rewrite to use "chapter", or another base, it works. Mainly I'm wondering if there's a way to fix this, and what could be causing this. It has to do with the fact that the category still existed when the CPT was initially added, but I can't quite nail it down. Here's the website where you can see it in action: http://dev1.abileneloving.com Here's my code for the CPT/Custom Tax/Custom Permalink Structure:               function chapter_post_type_init() {             $labels = array(                     'name' => 'Chapters',                     'singular_name' => 'Chapter',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Chapter',                     'edit_item' => 'Edit Chapter',                     'new_item' => 'New Chapter',                     'all_items' => 'All Chapters',                     'view_item' => 'View Chapter',                     'search_items' => 'Search Chapters',                     'not_found' =>  'No chapters found',                     'not_found_in_trash' => 'No chapters found in Trash',                     'parent_item_colon' => '',                     'menu_name' => 'Books'             );                  $args = array(                     'labels' => $labels,                     'public' => true,                     'publicly_queryable' => true,                     'show_ui' => true,                     'show_in_menu' => true,                     'query_var' => true,                     'rewrite' => array( 'slug' => 'books/%book_type%'),                     'capability_type' => 'post',                     'has_archive' => true,                     'hierarchical' => false,                     'menu_position' => 100,                     'supports' => array( 'title', 'editor', 'author', 'excerpt')             );             register_post_type( 'chapter', $args );     }     add_action( 'init', 'chapter_post_type_init' );          function book_tax_init() {             $labels = array(                     'name'              => _x( 'Books', 'taxonomy general name' ),                     'singular_name'     => _x( 'Book', 'taxonomy singular name' ),                     'search_items'      => __( 'Search Books' ),                     'all_items'         => __( 'All Books' ),                     'edit_item'         => __( 'Edit Book' ),                     'update_item'       => __( 'Update Book' ),                     'add_new_item'      => __( 'Add New Book' ),                     'new_item_name'     => __( 'New Book Name' ),                     'menu_name'         => __( 'Books' ),             );                  $args = array(                     'hierarchical'      => true,                     'labels'            => $labels,                     'show_ui'           => true,                     'show_admin_column' => true,                     'query_var'         => true,                     'rewrite' => array( 'slug' => 'books/%book_type%')             );             register_taxonomy(                     'book',                     'chapter',                     $args             );     }          add_action( 'init', 'book_tax_init' );          add_filter('post_type_link', 'book_permalink_structure', 10, 4);     function book_permalink_structure($post_link, $post, $leavename, $sample)     {         if ( false !== strpos( $post_link, '%book_type%' ) ) {             $book_type_term = wp_get_object_terms( $post->ID, 'book' );             $post_link = str_replace( '%book_type%', array_pop( $book_type_term )->slug, $post_link );         }         return $post_link;     }      **Update - New Code**               function chapter_post_type_init() {             $labels = array(                     'name' => 'Chapters',                     'singular_name' => 'Chapter',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Chapter',                     'edit_item' => 'Edit Chapter',                     'new_item' => 'New Chapter',                     'all_items' => 'All Chapters',                     'view_item' => 'View Chapter',                     'search_items' => 'Search Chapters',                     'not_found' =>  'No chapters found',                     'not_found_in_trash' => 'No chapters found in Trash',                     'parent_item_colon' => '',                     'menu_name' => 'Books'             );                  $args = array(                     'labels' => $labels,                     'public' => true,                     'publicly_queryable' => true,                     'show_ui' => true,                     'show_in_menu' => true,                     'query_var' => true,                     'rewrite' => array( 'slug' => 'books/%book%'),                     'capability_type' => 'post',                     'has_archive' => true,                     'hierarchical' => false,                     'menu_position' => 100,                     'supports' => array( 'title', 'editor', 'author', 'excerpt')             );             register_post_type( 'chapter', $args );     }     add_action( 'init', 'chapter_post_type_init' );          function book_tax_init() {             $labels = array(                     'name'              => _x( 'Books', 'taxonomy general name' ),                     'singular_name'     => _x( 'Book', 'taxonomy singular name' ),                     'search_items'      => __( 'Search Books' ),                     'all_items'         => __( 'All Books' ),                     'edit_item'         => __( 'Edit Book' ),                     'update_item'       => __( 'Update Book' ),                     'add_new_item'      => __( 'Add New Book' ),                     'new_item_name'     => __( 'New Book Name' ),                     'menu_name'         => __( 'Books' ),             );                  $args = array(                     'hierarchical'      => true,                     'labels'            => $labels,                     'show_ui'           => true,                     'show_admin_column' => true,                     'query_var'         => true,                     'rewrite' => array( 'slug' => 'books')             );             register_taxonomy(                     'book',                     'chapter',                     $args             );     }          add_action( 'init', 'book_tax_init' );          add_filter('post_type_link', 'book_permalink_structure', 10, 4);     function book_permalink_structure($post_link, $post, $leavename, $sample)     {         if ( false !== strpos( $post_link, '%book%' ) ) {             $book_type_term = wp_get_object_terms( $post->ID, 'book' );             $post_link = str_replace( '%book%', array_pop( $book_type_term )->slug, $post_link );         }         return $post_link;     }


title: Remove submenu item from list

text: I have the following script within my `functions.php` file to avoid certain users from modifying things they shouldn't and would like to remove one more item, the _Appearances > Themes_ submenu.               function remove_menus () {     global $menu;         $restricted = array(__('Dashboard'), __('Posts'), __('Pages'), __('Comments'), __('Plugins'), __('Users'), __('Tools'), __('Links'), __('Settings'));         end ($menu);         while (prev($menu)){             $value = explode(' ',$menu[key($menu)][0]);             if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}         }     }     add_action('admin_menu', 'remove_menus');      How would I be able to achieve this?


title: Use Editorial Calendar on any other page within any other plugin

text: I want to show Editorial Calendar on my custom plugin's page, so how to do that? Plugin available on http://wordpress.org/support/plugin/editorial-calendar Now I tried to include edcal.php (plugin page) but its showing me `Cannot redeclare class EdCal in` due to two time declaration of that class, so now hot to display same plugin page on my page? I tried `include( plugin_dir_path( __FILE__ ). 'edcal.php');`


title: Work with xml file and Wordpress

text: by a URL that generate an XML page, example: http://thegamesdb.net/api/GetGame.php?id=2 how can import it in Wordpress site with mapped request custom field? thanks Stew


title: Custom post types, taxonomies, and permalinks

text: This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex). I have a custom post type "product_listing" and a custom taxonomy of "product_cat" (which is hierarchical and should be have like categories). I simply want my URLs to look like this:               mysite.com/products/category1/product-name1      mysite.com/products/category2/product-name2      But for the life of me, no matter what I do, I'm getting the dreaded 404 issue. Pages work okay, and Posts work okay, but my custom posts don't work correctly. They're showing up as:               mysite.com/products/product-name1     mysite.com/products/product-name2      Which actually _works_! It's just that I want to see my custom taxonomy in there, PLUS, I want to be able to access the taxonomy.php template I have setup by going to:               mysite.com/products/category1/     mysite.com/products/category2/      None of my slugs are the same, nor do I want them to be. Here is the post type and taxonomy part of my functions.php file:               ///// CUSTOM POST TYPES /////               // register the new post type         register_post_type( 'product_listing',             array( 'labels' => array(                 'name' => __( 'Products' ),                 'singular_name' => __( 'Product' ),                 'add_new' => __( 'Add New' ),                 'add_new_item' => __( 'Create New Product' ),                 'edit' => __( 'Edit' ),                 'edit_item' => __( 'Edit Product' ),                 'new_item' => __( 'New Product' ),                 'view' => __( 'View Products' ),                 'view_item' => __( 'View Product' ),                 'search_items' => __( 'Search Products' ),                 'not_found' => __( 'No products found' ),                 'not_found_in_trash' => __( 'No products found in trash' ),                 'parent' => __( 'Parent Product' ),                 ),                 'description' => __( 'This is where you can create new products on your site.' ),                 'public' => true,                 'show_ui' => true,                 'capability_type' => 'post',                 'publicly_queryable' => true,                 'exclude_from_search' => false,                 'menu_position' => 2,                 'menu_icon' => get_stylesheet_directory_uri() . '/images/tag_orange.png',                 'hierarchical' => true,               '_builtin' => false, // It's a custom post type, not built in!                 'rewrite' => array( 'slug' => 'products', 'with_front' => true ),                 'query_var' => true,                 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' ),                 )     );                    //hook into the init action and call create_book_taxonomies when it fires     add_action( 'init', 'create_product_taxonomies', 0 );     //add_action('admin_init', 'flush_rewrite_rules');          //create two taxonomies, genres and writers for the post type "book"     function create_product_taxonomies()      {       // Add new taxonomy, make it hierarchical (like categories)       $labels = array(         'name' => _x( 'Categories', 'taxonomy general name' ),         'singular_name' => _x( 'Category', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Categories' ),         'all_items' => __( 'All Categories' ),         'parent_item' => __( 'Parent Categories' ),         'parent_item_colon' => __( 'Parent Categories:' ),         'edit_item' => __( 'Edit Category' ),          'update_item' => __( 'Update Category' ),         'add_new_item' => __( 'Add New Category' ),         'new_item_name' => __( 'New Category Name' ),         'menu_name' => __( 'Category' ),       );                register_taxonomy('product_cat',array('product_listing'), array(         'hierarchical' => true,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         //'rewrite' => true,         'rewrite' => array( 'slug' => '%category%', 'with_front' => true ),       ));            // Add new taxonomy, NOT hierarchical (like tags)       $labels = array(         'name' => _x( 'Scents', 'taxonomy general name' ),         'singular_name' => _x( 'Scent', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Scents' ),         'popular_items' => __( 'Popular Scents' ),         'all_items' => __( 'All Scents' ),         'parent_item' => null,         'parent_item_colon' => null,         'edit_item' => __( 'Edit Scent' ),          'update_item' => __( 'Update Scent' ),         'add_new_item' => __( 'Add New Scent' ),         'new_item_name' => __( 'New Scent Name' ),         'separate_items_with_commas' => __( 'Separate scents with commas' ),         'add_or_remove_items' => __( 'Add or remove scents' ),         'choose_from_most_used' => __( 'Choose from the most used scents' ),         'menu_name' => __( 'Scents' ),       );             register_taxonomy('scent','product_listing',array(         'hierarchical' => false,         'labels' => $labels,         'show_ui' => true,         'query_var' => true,         //'rewrite' => array( 'slug' => 'scents' ),       ));     }      I also have another custom taxonomy of "scents" that I'd ideally like to have some kind of friendly url but I'm more open on this. I'd like to maybe access a list of all scents by going to **mysite.com/products/scents** but they don't have to be category specific. Can anybody help me? I've been going crosseyed for hours. Thanks!


title: Custom taxonomy category slug not being included in permalink

text: I'm having difficulty implementing a permalink scheme with a custom post type ('widget') and its taxonomy ('widgetscategory'). Visually, this is the permalink structure that I am after:               /widgets/ (a page handled by the page-widgets.php template)     /widgets/red/ (a category view handled by the taxonomy-widgetscategory.php template)     /widgets/red/acme-widget-5000/ (a post handled by the single-widgets.php template)      However, with my current code, if I put create a new widget custom post, and give it the widgetscategory of 'red', Wordpress will generate a permalink as follows:               /widgets/%widgetscategory%/acme-widget-5000/      This obviously does not work, because of the %widgetscategory%. If I adjust the URL manually to be:               /widgets/red/acme-widget-5000/      then everything works as expected. **How can I get the %widgetscategory% to be replaced by the actual category in the permalinks that Wordpress generates?** I assume I am missing something with the 'rewrite' parameter of the register_post_type function, but I can't seem to fix it! Here is the code I am using to set up the custom post type and taxonomy:               add_action( 'init', 'custom_post_widget_product' );          //Set up widget Post Type     function custom_post_widget_product() {              register_post_type('widgets', array(             'label' => __('widgets'),             'singular_label' => __('widget'),             'public' => true,             'show_ui' => true,             'hierarchical' => true,             'rewrite' => array( 'slug' => 'widgets/%widgetscategory%' ),             'publicly_queryable' => true,             'query_var' => true,             'has_archive' => true,             'with_front' => false,             'supports' => array('title','editor','thumbnail','excerpt'),             'taxonomies' => array('widgetscategory'),         ) );          //Set up widget Categories         register_taxonomy('widgetscategory', 'widgets', array(             'hierarchical' => true,             'label' => 'widget Categories',             'singular_label' => 'widget Category',             'rewrite' => array( 'slug' => 'widgets' ),         ) );          }      Thank you!


title: Custom Permalinks for Custom Taxonomies/Post Types -> Top Level Pages not working

text: I have created a custom post type called "artists". These are categorized by the custom taxonomy "style". I do have this: > ./photography/edward-example (single page with details) > > ./photography/ (archive page which lists all artists in "category"/custom > taxonomy "style" "photography") (for example: photography as style, Edward Example as artist) I achieved this because I used the technique described in this answer for the custom taxonomy. The problem is, now my other pages (e.g. "./about") will not work. Can anybody help me out?


title: Change Permalink Structure for Custom Taxonomy

text: I have a custom taxonomy called `colors`, which contains the terms _Red_ , _Blue_ , _Yellow_ etc. Each post has a term of the taxonomy colors linked to it. The default permalink structure for posts is `/%category%/%post-name%/` i.e. posts are displayed at - `www.example.com/category-term/post-name` I want to change the permalink structure such that the posts are displayed at `www.example.com/taxonomy-term/post-name` i.e. `www.example.com/yellow/post- name` \- for a post that has the term _Yellow_ of the custom taxonomy linked to it. Please suggest any method to do this..?


title: Custom Post Type - Rewrite slug

text: I have a custom post type (products) that I would like to change the slug for. I have a main product page that shows all product categories. After clicking on the category, it shows all products in that category. When clicking on one of the products it should take you to the custom post type product. The problem is that I want the url to be www.example.com/products/{category}/{product}, but from the custom post type, the url I get is www.example.com/products/{product}. When I registered the custom post type, I set rewrite to               'rewrite' => array('slug' => 'products', 'with_front' => false),      How can I fix this to include whatever category the post type is in?


title: wordpress content .php file in an iframe's src in a wordpress post

text: I'm stuck with the following issue : I would like to insert an iframe with a wordpress content inside a wordpress post. I explain myself. I have two things : a post and a presentation. In the the_content() wordpress fitler, I add my iframe to the $content. This iframe has a src pointing to a custom .php file, and inside this .php I want to have access to my loop but I can not manage to do it. So I cheat and pass the ID of the post through the URL so my iframe code is :               <iframe src=\"".WP_PLUGIN_URL."/presentation/embedded_presentation_iframe.php?postid=". get_the_ID() ."\" id=\"embedded-frame-presentation\"      And inside my .php I use this :               $postid = $_GET["postid"];     ...     echo do_shortcode( get_post_meta($postid, 'awp_slides', true) );       The issue now is that I have some plugins adding some possible shortcodes and my shortcodes are transformed into plugins syntaxes, but since my .php file is outside the wordpress loop, the transformed shortcodes are not applied in my iframe... So I think I have two ways for solving that but I don't know how to do both :   1. I try to put my .php file (which is the src of iframe) into the loop of wordpress, I don't know how so my $content is process and the plugins are applied to my iframe   2. Or maybe a function exist in wordpress which would be my $content but already processed so instead of using `do_shortcode( get_post_meta($postid, 'awp_slides', true) );` I could use something like apply_plugins(do_shortcode( get_post_meta($postid, 'awp_slides', true) ))  Thanks for your help ! I'm really stuck here :) I hope you will understand me...


title: Default calendar widget not showing up

text: I just started learning how to make custom websites with this (unfortunately) most popular CMS, and I am having a small issue. I widgetized some areas of my website, and some widgets (I tested 3, text, menu and categories) show up normally, but when I put the calendar widget there (the one that comes with wordpress) it just doesn't show up. What do you think can be the problem? Thanks


title: jQuery to work on WP custom page template

text:
I have a simple jQuery script to enable an image mouseover hover effect that I want to use on my WP custom page template but it isn't yet working for me and I assume it is not linking to jQuery. The hover image does not display. Here is part of the page template code (theme=Twenty_Eleven)               <?php     /**      * Template Name: rpdcustompagetemplateportfolio      *      * @package WordPress      * @subpackage Twenty_Eleven      * @since Twenty Eleven 1.0      */          get_header(); ?>

                     <img src="<?php bloginfo('template_directory'); ?>/images/logobutton50pc.png" alt="My button" class="logobutton" />
Portfolio
      I always get some problem using jQuery & WordPress unfortunately! I assume this is the problem that jQuery not linked/working here. I am most grateful for help & advice, and look forward to replies, many thanks (NB for some reason I cannot cut/paste the code in properly here either..apologies)


title: admin edit member profile on front-end

text: I've seen that nobody answered to this question: Let admin users edit member profiles from front end Is there a way to allow Admin editing members/users profile on front-end? Thank you.


title: Programmatically add posts from specific category to menu

text:
I am wanting to add individual posts to my primary menu programatically based on category I have used the wp_nav_menu_items filter previously to add pages to the menu but I am stuck when it comes to adding posts.               add_filter( 'wp_nav_menu_items', 'fx_user_menu', 10, 2 );          function fx_user_menu( $items, $args ) {         if ($args->theme_location == 'primary') {             $myposts = get posts from specified category                 foreach ( $myposts as $post ) {                 $items .= '
' . the_title() . '
';                 }         }            return $items;     }      Any ideas on how to get this working?


title: Programatically retreive page content from its template page

text:
I am building a menu and representing it to the front-end in Accordion style using the foundation front-end framework. The Wordpress admin drags and drops menu items (pages, posts, custom posts, categories, whatever) into the menu from Appearance -> Menus as normal. My code loops through every menu item in the menu and displays it along with its content. For example, if the loop encounters an **about page** in the menu, it displays **About** as a list item label (clickable) and its content (hidden) beneath it. Site visitors clicks on About to reveal the about page content in accordion fashion. What is the best approach to get this done? I mean the loop and content retrieval. I made an attempt as of the code below.               About       about page content (text/ starts as hidden)     Contact        contact page content (text/ starts as hidden)     Solutions        HEALTHCARE (label)         Healthcare solution 1 (link)         Healthcare solution 2 (link)       PROFESSIONAL SERVICES (label)         Prof service 1 (link)         prof service 2 (link)      I wrote the following code and I partially succeeded:               <?php        $menu_name = 'primary';            if( ($locations = get_nav_menu_locations()) && isset($locations[$menu_name]) ) {         $menu = wp_get_nav_menu_object( $locations[$menu_name] );         $menu_items = wp_get_nav_menu_items($menu->term_id);     ?>
            <?php foreach( (array) $menu_items as $key => $menu_item ) { ?>         <?php if ($menu_item->object == 'page'): ?>           <?php             $id = get_post_meta($menu_item->ID, '_menu_item_object_id', true);              $page = get_page($id);             //$template_name = get_post_meta($id, '_wp_page_template', true);?>
            <a href="#panel<?php echo $menu_item->ID;?>"><?php echo $menu_item->title; ?>             <div id="panel<?php echo $menu_item->ID;?>" class="content">           <?php                  if($page->post_title == 'Contact'): /* DIRTY:PROBLEM IS HERE */                    get_template_part('contact'); /* NOT GOOD, very had coded */                 else: echo apply_filters('the_content', $page->post_content); endif; /* I LIKE THIS MORE */?>

        <?php elseif($menu_item->object == 'solutions_category'): /* CUSTOM POST TYPE */?>        <?php /* REST OF THE CODE ... */ ?>        <?php endif;?>      <?php } ?>
          It works fine that way, but the problem lies in the 'Contact' page because it only uses a template page for its content (the page text editor is empty). As you can see I am explicitly checking if post_title is Content in order to use get_template_part. This is definitely bad and not desired. Is there a generic solution capable of retrieving page content despite if content is from template, settings page or the text editor itself? Thanks in advance.


title: Rich Snippets for Wordpress

text: Rich Snippets look like a good tool for the webmaster's toolbox. Do you know of any way of integrating Rich Snippets into Wordpress?


title: Using php inside javascript

text:
I have got the following code in a javascript(jquery) file called custom.js:                    var gapinvite = new Date();                   gapinvite = new Date(2014, 06 - 1, 2);         $('.days').countdown({             until: gapinvite,             layout: '{dn} {dl}',                  /* Set your timezone */             timezone: +7         });      1.Now i want a user to be able to change the above date. I have created a theme options page called theme-options.php 2.I am using `<?php require_once('theme-options.php'); ?>` in the functions.php to link to theme-options.php. 3.This is theme-options.php:               <?php     add_action('admin_menu', 'director_create_menu');     function director_create_menu() {     add_submenu_page( 'themes.php', ' Theme Options',     'Theme Options', 'administrator', __FILE__,     'director_settings_page');     add_action( 'admin_init', 'director_register_settings' );     }     function director_register_settings() {     register_setting( 'director-settings-group', 'director_date' );     }          div class="wrap">
Theme Settings
       <form id="landingOptions" method="post" action="options.php">         <?php settings_fields( 'director-settings-group' ); ?>

               Date:	                                <input type="text" placeholder="2014, 06 - 1, 2" name="director_date"                 value="<?php print get_option('director_date');                 ?>" />

           Time Zone:	                        <input type="text" placeholder="+5" name="director_timezone"             value="<?php print get_option('director_timezone');             ?>" />

             <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>"   />
           </form>
         <?php } ?>      Basically what is happening is that there is a theme options page.A user gives a date inside it. Now i want to use that date inside the javascript file. If I had to use it inside index.php it would've been               <?php $date = get_option('director_date'); ?>     <?php if( $date ) : ?> <?php echo $date; ?><?php endif; ?>);      and               <?php $timezone = get_option('director_timezone'); ?>     <?php if( $timezone ) : ?> <?php echo $timezone; ?><?php endif; ?>);      . However this is javascript. How do i implement such an action here?


title: Add share links to all blog posts on homepage

text: I need to figure out a way to add share links to each blog post on the homepage. This way users can share specific posts without actually going into the post. Is there a way to do this easily through a WP plugin? The only tricky thing to me is they will be sharing URLs from pages which they are not actually on so I'm unsure how to proceed with that.. does anyone have any ideas? Thanks!


title: Website loading slowly - Advanced Custom Fields images

text: I'm currently using `get_field` with Advanced Custom Fields plugin (see here) to get a single image for search results. The end result is that these pages are loading slow, as I believe this is due to MySQL returning the whole array of all images in the gallery for the specified page, which ends up being huge. To load the image, I am currently doing the following:               $image = get_field('house_photos');               if ($image) {                  echo '<img src="' . $image[0]['sizes']['house_search'] . '"  />';               }       Is there a more efficient way just to get this single image without requesting the entire array?


title: Get ID and slug from taxonomy object

text:
I have a custom field to select a category (custom taxonomy) and then I will display a list of all of its child-categories. This works fine when I return the custom field as "term_id." HOWEVER. I would like to also get the slug from this selected category (the parent) so I can link to its category page (I don't think I can link to it with the ID). So I thought maybe I should return the custom field as an object instead. This is what it dumps:                stdClass Object ( [term_id] => 122 [name] => Quick Release Watch Bands [slug] => fits-all [term_group] => 0 [avhec_term_order] => 0 [term_taxonomy_id] => 122 [taxonomy] => product_cat [description] => Watch bands in many colors [parent] => 0 [count] => 293 [meta_id] => 1 [woocommerce_term_id] => 122 [meta_key] => order [meta_value] => 22 )       Do you know how I can pull out both the ID (122) and the slug (fits-all) from this? Here is my code so far. The custom field is called "selected_category".               <?php $catid = get_sub_field('selected_category');                        $args = array(                   'taxonomy'     => 'product_cat',                   'orderby'      => 'name',                   'show_count'   => 0,                   'pad_counts'   => 0,                   'hierarchical' => 1,                   'title_li'     => '',                   'depth'        => 1,                   'child_of'     => $catid                 );                      ?>
<?php the_sub_field('title'); ?>

     <?php wp_list_categories( $args ); ?>
      Can anyone help me, please? Thank you so much!


title: wordpress head is empty, append to body

text: i'm have a problem for Wordpress heading. my get_header();               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>     <head>     <title>     <?php wp_title('«', true, 'right'); ?>     <?php bloginfo('name'); ?>     </title>     <meta name="language" content="tr-TR" />     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">     <meta name="location" content="türkiye, tr, turkey" />     <meta name="robots" content="all" />     <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />     <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />     <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />     <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.css" type="text/css" />     <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/fa/css/font-awesome.min.css" type="text/css" />     <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>     <script src="<?php bloginfo('template_url'); ?>/eiddia.js" type="text/javascript"/></script>     <!--[if gte IE 9]>       <style type="text/css">         .gradient {            filter: none;         }       </style>     <![endif]-->     <?php wp_head();?>     </head>     <body>     ...     </body>     </html>      The Result ![http:/www.bilgius.com/wp- content/uploads/videos/theResultHeadingWp.png](http://i.stack.imgur.com/akkJi.png) _It looks like your post is mostly code; please add some more details._


title: How do I create a custom archive page that my client can edit?

text: * I've created a custom post type.    * I have set has_archive as true and understand I could also set it to has_archive => 'ctp'   * I also know that if I name a template file archive-cpt.php Wordpress will use this template for my cpt. This is okay for some situations. But I'd like my client to be able to go to an editing page, like default posts and pages in the admin area. I have thought about making the archive-cpt.php a template that can be called in a default page. Making that page the archive. Am I on the right track? I'd really like to do this with the most up to date WordPress method.


title: Implementing HTML/CSS menu in WordPress theme

text: I have an HTML/CSS template having a horizontal menu. I need to convert the template into a WordPress theme. I am stuck with the menu. I have used the wp_nav_menu function in my header.php file and have also completed the functions.php file. The menu is now displaying vertically with bullets. I need to implement the menu now, but am unable to find and associate the proper css class to the menu_class parameter. Kindly assist. Thanks and Regards Debashis


title: Adding Image Description below Images Inserted into Posts

text: I've got a bunch of images inserted into posts with metadata I'd like to display underneath them: some have caption, some have description, some have both. I've figured out how to filter img_caption_shortcode to display the description. The problem is that this is apparently called only when there is a caption. So if I want to display an image description under an image with no caption, this doesn't appear to be a solution. What I'd like to know is how to either:   * Hook into the inline image formatting to display exactly what I want (can't figure this out for the life of me, have dug through all the code and don't see where img_caption_shortcode gets auto-applied to inline images), or   * force img_caption_shortcode to be applied to all images which have a description (regardless of whether they have captions) The more semantic way would definitely be the first, but either would make me happy :) To avoid the inevitable suggestions: no, I can't change where I store the metadata, putting it all in the caption or something - there is a large number of images which woud nee to be thus edited, and an undue amount of effort would be required, besides the fact that we're using them for two separate purposes (one is for a description, one is for copyright info); and, no, we aren't satisfied to use shortcodes to accomplish this, as it would require going back into many posts and editing a huge amount of data, with the risk of missing some. (I guess it would be possible to filter the content and pull the metadata from the image within the tag, but that seems like it would be a lot messier. I'd prefer a cleaner solution if possible.)


title: Custom fields not saving in newest Wordpress 3.0.1

text:
I had this working a couple of weeks ago and the only thing I can think is that WordPress has updated and broken the functionality? I followed the tutorial here to add custom fields: http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes- using-custom-post-types/ It was working fine (I entered about 50 custom posts all with custom fields) but when I go to edit it today any changes I make to the custom fields are not being saved, although other changes work fine. Does anyone know if this is a known bug? **Edit:** Here is the code, added in functions.php to a brand new install (theme: twentyten)               add_action('init', 'testimonials_register');     add_action("admin_init", "admin_init");     add_action('save_post', 'save_testimonial');                         function testimonials_register() {         $args = array(             'label' => __('Testimonials'),             'singular_label' => __('Testimonial'),             'public' => true,             'show_ui' => true,             'capability_type' => 'post',             'menu_position' => 5,             'hierarchical' => false,             'rewrite' => true,             'supports' => array('title', 'editor', 'thumbnail','custom-fields', 'revisions', 'excerpt', 'page-attributes')         );              register_post_type( 'testimonials' , $args );     }                         register_taxonomy( 'testimonial_project_type', array("testimonials") , array( 'hierarchical' => true, 'label' => 'Project Type', 'query_var' => true, 'rewrite' => true ) );                    function admin_init(){         add_meta_box("testimonialInfo-meta", "Testimonial Options", "meta_options_testimonial", "testimonials", "advanced", "high");          }                    function meta_options_testimonial(){         global $post;         $custom = get_post_custom($post->ID);         $name = $custom["name"][0];         $position = $custom["position"][0];         $project_url = $custom["project_url"][0];         $website = $custom["website"][0];         ?>       Name: <input size="50" name="name" id="name" value="<?php echo $name; ?>" />
       Position: <input size="50" name="position" id="position" value="<?php echo $position; ?>" />
       Website Name: <input size="50" name="website" id="website" value="<?php echo $website; ?>" />
       Project slug: <input size="50" name="project_url" id="project_url" value="<?php echo $project_url; ?>" /> E.g. 'parker-harris'
         <?php     }              function save_testimonial(){     $custom_meta_fields = array( 'project_url','name','position','website');     foreach( $custom_meta_fields as $custom_meta_field ):         if(isset($_POST[$custom_meta_field]) && $_POST[$custom_meta_field] != ""):             update_post_meta($post->ID, $custom_meta_field, $_POST[$custom_meta_field]);         endif;     endforeach;                   }                                                 add_filter("manage_edit-testimonials_columns", "testimonials_edit_columns");           add_action("manage_posts_custom_column",  "testimonials_custom_columns");                function testimonials_edit_columns($columns){           $columns = array(               "cb" => "<input type=\"checkbox\" />",               "title" => "Testimonial Title",               "name" => "Name",               "description" => "Excerpt",               "project_url" => "Project Slug"         );                return $columns;          }                function testimonials_custom_columns($column){           global $post;           switch ($column)           {               case "name":                   $custom = get_post_custom();                   echo $custom["name"][0].", ".$custom["position"][0]."
 ".$custom["website"][0];                 break;               case "description":                   the_excerpt();                  break;               case "project_url":                   $custom = get_post_custom();                   echo "".$custom["project_url"][0]."";                 break;           }           }                                                        // This shows testimonials in blog and feed.              add_filter( 'pre_get_posts', 'my_get_posts' );              function my_get_posts( $query ) {          if ( is_home() && false == $query->query_vars['suppress_filters']  || is_feed() )         $query->set( 'post_type', array( 'post', 'testimonials') );          return $query;         }


title: How to display nothing (instead default) when no user gravatar is present?

text: Is there a way to show no gravatar in comment list for the commenters that are not registered at gravatar.com? As much as I saw, gravatar.com doesn't return a special code when no avatar is registered. The temporary, not so elegant solution I applied for the moment is displaying a transparent 1x1px gif but I'd like to return no image if possible. I've also tried 3-4 gravatar plugins but none does this properly.


title: Create static front-page with 3-5 recent posts

text:
I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the _Underscore boilerplate_. As I understands, the codex suggests that I create a front-page.php and customize it there. In _setting>reading_ I selected A static/Front page (my desired page where I change the static welcoming message). Underneath I want to have 3-5 recent posts with thumbnails (enabled in my functions) and excerpts. My front-page.php:                                 <?php while ( have_posts() ) : the_post(); ?>                      <?php get_template_part( 'content', 'page' ); ?>                  <?php endwhile; // end of the loop. ?>
Recent Posts

             <?php                 $args = array( 'numberposts' => '5' );                 $recent_posts = wp_get_recent_posts( $args );                 foreach( $recent_posts as $recent ){                     echo '
' .   $recent["post_title"].'
 ';                 }             ?>
                This works, however I have no clue how to load thumbnails + excerpts. Most importantly is this correct?


title: CSV import stopped working when I upgraded to WP 3.5.2

text: I used to import Greek text in posts using various plug-ins such as CSV improter. All these stopped working once I upgraded WP to 3.5.2 Any known issues? Thanks.


title: Preventing 404 error on empty date archive

text: On a date archive page when no posts exist (for that date) WordPress throws across to the 404 page. Is there a way to make WordPress continue to use the original archive instead of the 404. That way I can use `if ( have_posts() )` condition to output a "No posts found" message.


title: How to hack YARPP plugin to find related posts for custom post type?

text: Does anybody knows how I can hack YARPP (Yet-Another-Related-Post-Plugin) to find related posts for custom post type? I really can't find any better related post plugin than YARPP. But, unfortunately, it does not support custom post-type yet. Cheers!


title: How to manage attachment relationships for specific posts in WP 3.5+

text: In WordPress 3.5, media management has changed entirely. Also, relating attachments to specific posts is (I believe) basically only being done for backward compatibility. Therefore, after uploading attachments from within the media modal to a post of any post type, it establishes a relationship where the post ID is the parent of the attachment ID, like it's been for a long time. However, once an attachment is uploaded to a post, there is no place to manage attachments that have a relationship to the post from within the media modal on the post. After I upload the images, I can immediately select and insert them, but because the media gets dumped into the site-wide media section, I can no longer manage attachments to a specific post like in < 3.5 as seen here: ![enter image description here](http://i.stack.imgur.com/wpm7O.png) This creates the following issue: Managing relationships of attachments to specific posts is impossible without completely deleting the media and re-uploading. That alone is not different from before. However, now that media is dumped into the same tab as all other media, and there's not a tab to manage media w/ a relationship to a specific post, it becomes incredibly difficult to even find the media attached to a specific post down the road. Because you could attach media to a post, and then down the road, after many attachments have been uploaded to other posts, you want to go back to an old post (think a slider or product) and change out the attached media. Good luck finding your media, because the media tab in the new editor does not order all media first by those attachments with a relationship to the current post. Here's the example pic: ![enter image description here](http://i.stack.imgur.com/pOE5H.jpg) Not so bad here, because it's only one or two posts separated. But imagine going back months later. It's impossible to find the related attachments for that post. There are many, many plugins, and custom page templates out there that utilize the relationship between a post and it's related attachments. So removing those relationships is going to be very, very hard in the future. I assume the answer is to create another tab on the left for the media attached to a particular post. Or to make the orderby for the media tab start with attachments that are related to the current post. That's a short term fix. Long term, other ways to relate media to a post need to be created by these plugin and theme developers. I assume there are available hooks to create new tabs, and to add meta data to the attachment and post to create the relationship. Am I right in my concern? Ideas to fix?


title: Same term from custom taxonomy in two different custom post types?

text:
I use a front end form to insert custom post types, an input is used for inserting terms (keywords) to a custom taxonomy for this custom post type. I just noticed in the back-end when I view the terms list in the taxonomy. Only one unique term has been added even if I create multiple posts and use the same terms in each. Though in the back-end it does say how many custom posts the term is associated with. From the back-end I get an error when trying to add a duplicate term. That's expected. I read though that WordPress in some cases creates a duplicate but the slug is unique. On my custom post type single template page I have this function to list the terms               $keyword_terms = wp_get_object_terms($post->ID, 'keyword');     if(!empty($keyword_terms)){       if(!is_wp_error( $keyword_terms )){         echo '
';         foreach($keyword_terms as $term){           echo '
slug, 'keyword').'">'.$term->name.'
';          }         echo '
';       }     }      The slug / term link is the same on all the custom posts. Is that normal behavior of WordPress with custom taxonomies/terms? Is there a function to use to have the terms inserted and unique slugs generated?


title: Right align a youtube video

text: I'm trying to right align (class="alignright") a YouTube video AND allow my client to edit the surrounding text in the future using the visual editor. I simply added class="alignright" to the tag containing the embed using the HTML editor however when any changes are made to the text using the visual editor WordPress strips the extra code. I think it might be impossible to get the result that I want but could anyone confirm my suspicions or give me a workaround.


title: Can 'Custom Field' data be inserted into this Short Code?

text: I have created a custom page template. In the template, I use a shortcode for JJ NextGen JQuery Slider. I would like the page to have a 'custom field' called 'Image Gallery' with a value that derives from NEXTGEN Gallery. I am trying to get the page template to recognize the dynamic input of the value from the shortcode but I haven't had success. Any advice is much appreciated! Here is the code I am using:               <div id="prop_images">                     <?php echo do_shortcode('[jj-ngg-jquery-slider title="Property" gallery="get_post_meta($post ->ID, 'Image_Gallery', true)" effect="fade" html_id="about-slider" width="400" height="300"]'); ?>                     </div><!-- end prop images-->


title: Custom Table Column Sortable by Taxonomy Query

text: I am looking to add a custom column to a custom post type post listing table in the dashboard. I have read many questions / answers on WPSE, along with this article. Although, it seems like everyone wants to query by meta key / value. I am trying to add a taxonomy value (basically a category) to a custom post type table. I would like the column to be sortable, however I am not understanding the query adjustment. Add the column title.               function mbe_column_titles($columns){         $columns['title'] = 'Frequently Asked Question';         $columns['mbe-faq-category'] = 'Category';         return $columns;     }     add_filter('manage_mbe-faqs_posts_columns', 'mbe_column_titles');      Add the row values.               function mbe_column_rows($column_name, $post_id){         if($column_name == 'mbe-faq-category'){             $categories = wp_get_object_terms($post_id, 'mbe-faq-categories');             $the_category = array();             if($categories){                 foreach($categories as $category){                     $the_category[] = $category->name;                 }             }             echo join(', ', $the_category);         }     }     add_action('manage_mbe-faqs_posts_custom_column', 'mbe_column_rows', 10, 2);      Prepare the ordering key,               function mbe_sortable_columns($columns){         $columns['mbe-faq-category'] = 'mbe-faq-category';         return $columns;     }     add_filter('manage_edit-mbe-faqs_sortable_columns', 'mbe_sortable_columns');      I am stumped on how to actually sort the column by the FAQ Category. I would assume this would be a taxonomy query. I am too embarrassed to even post my attempt of handling this, and everything I do seems to fail. I would like to use the `pre_get_posts` filter to handle this if possible.


title: Safe to say WordPress security releases don't have database upgrades

text: Since all security releases are based on last released codebase + security patch, I think its safe to say WordPress security releases don't have database upgrades, but I figured I will ask my fellow developers here. Does anyone know of a security release which had one? Or can anyone think of a case where it might have a database upgrade code within it?


title: Count posts published in one particular day: the lighter way

text: I would like to get just the number of posts published in one particular day. I'm using this code, but this retrieve lot of code:               $day = date('Ymd');     $query01 = array('numberposts' => -1, 'post_type' => array('post', 'video', 'image', 'review'), 'm' => $day);     $mypost = get_posts($query01);     $counter = count($mypost);     wp_reset_postdata();      Is there a lighter way to obtain the same?


title: How To Create a Fluid Grid Style Layout For WordPRess Posts?

text: I know how to setup a masonry layout for WordPress but what I can't figure out is how to make each post's grid be a different size like the example image below. How do I achieve that, is through jQuery?![enter image description here][1] http://i.stack.imgur.com/Ata6N.png


title: How to keep a Wordpress site synchronized between two servers?

text: I have a WordPress site running in a dedicated server in hosting A and I would like to keep it synchronized with a copy in another hosting server for fail over protection. Is that possible?


title: Best way to filter featured image text for a custom post type?

text: I am trying to change the "Set featured image", "Remove featured image", and "Use as featured image" text links of a custom post type for my plugin Meteor Slides. I found the "admin_post_thumbnail_html" filter hook, and came up with some code that will change "Set featured image" to "Set slide image" for just the slide post type:                   if ((isset($_GET['post_type']) && $_GET['post_type'] == 'slide') || (isset($post_type) && $post_type == 'slide')) {              add_filter( 'admin_post_thumbnail_html', 'meteorslides_set_featured', 9999, 1 );              function meteorslides_set_featured( $content ) {                  return str_replace( 'Set featured image', 'Set slide image', $content );              }          }      I tried the same thing for "Remove featured image" and it did not work, however I can use this code to make this change for _all_ post types:                   add_filter( 'admin_post_thumbnail_html', 'meteorslides_remove_featured', 9999, 1 );          function meteorslides_remove_featured( $content ) {              return str_replace( 'Remove featured image', 'Remove slide image', $content );          }      Does anyone have any thoughts as to why filtering "Set featured image" would behave differently than "Remove featured image"? Changing "Use as featured image" seems to be a bit trickier, there isn't a filter for this. But I did find a ticket in Trac where someone else was trying to do the same thing, and there was a suggestion to filter the translation string. This solution worked pretty well, I was able to change the "Use as featured image" text, but again it is for all post types and I'm not sure how to narrow it down:                   add_filter( 'gettext', 'meteorslides_use_featured', 9999, 4 );          function meteorslides_use_featured( $translation, $text, $domain ) {              $translations = &get_translations_for_domain( $domain );              if ( $text == 'Use as featured image' ) {                  return $translations->translate( 'Use as slide image' );              }              return $translation;          }      The overlaid media window doesn't seem to "know" that I am loading it from a certain post type, so I'm not sure if this change is doable. I did find an answer on here that showed how to change these links with jQuery. I'd prefer to use filters, but if I could figure out how to limit that to one post type that'd be alright too! I've been looking around at some other plugins that use featured images but I haven't been able to find any that have changed all of these strings. Has anyone pulled this off?


title: Creating two database tables via plugin

text: I'm working on a voting plugin for my site and I want to create 2 tables: one that stores votes and another that stores voter ips. In Codex it suggests to use an if statement to see if the table has already been created when installing the plugin but how can I alter the code if I'm creating 2 tables? This is my if statement in the plugin install function, currently set to check if 1 table already exists.               ...             $table_name1 = $wpdb->prefix . "voters_ip";        $table_name2 = $wpdb->prefix . "vote_posts";        $installed_ver = get_option( "postvote_version" );               if($wpdb->get_var("show tables like '$table_name'") != $table_name1) { //unsure how to add both tables                $sql = "CREATE TABLE " . $table_name1 . " (           id bigint(20) NOT NULL AUTO_INCREMENT,           vote_post_id bigint(20) NOT NULL,           voter_ip varchar(100) NOT NULL,           UNIQUE KEY id (id)         );";                $sql = "CREATE TABLE " . $table_name2 . " (           id bigint(20) NOT NULL AUTO_INCREMENT,           vote_post_id bigint(20) NOT NULL,           up int(11) NOT NULL,           ddown int(11) NOT NULL,           UNIQUE KEY id (id)         );";                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');           dbDelta($sql);                add_option("postvote_version", $postvote_version);        }          ....      What is the correct way to check if both tables exist?


title: How To Provide Sub-Blogs Their Own Domain Names?

text: I ran a search that did not yield that many results. Is it possible, and how can each sub-blog of a multi-site installation be given its own domain name?


title: Include multiple page ids in loop

text:
Haven’t slept in about 30 hours now, can someone please help as the below code doesn’t work, it just displays all posts etc :|               <?php $args = array       (             'page' => array(139, 54)       );            $loopy = new WP_Query($args);       while ($loopy->have_posts()) : $loopy->the_post(); ?>
<?php the_title();                    echo '
';                  echo '
';             endwhile;       ?>


title: Dropzone.js and wordpress plugin

text: I'm currently using Dropzone.js within a personal plugin and I'm able to create the dropzone, however when I pass in plugins_url as the action I'd like to get the files and add them to the wordpress media using the usual insert_attachment function found on the wordpress documentation. Dropzone:               <form id="udev-dropzone" method = "post" action="<?php echo plugins_url('/unrealdevs-portfolio/library/components/PortfolioUploader.php'); ?>" class="dropzone" enctype="multipart/form-data">         <input type="hidden" name="submitted" id="submitted" value="1" />     </form>      My statement in PortfolioUploader.php to check for files (I know I need to add a nonce):               if ( $_FILES ) {     $files = $_FILES;     $user = $_POST['user_id'];     foreach ($files['name'] as $key => $value) {         if ($files['name'][$key]) {             $file = array(                 'name'     => $files['name'][$key],                 'type'     => $files['type'][$key],                 'tmp_name' => $files['tmp_name'][$key],                 'error'    => $files['error'][$key],                 'size'     => $files['size'][$key]                 );                      $_FILES = array("upload_attachment" => $file);                 update_udevdb($user, $file); //Dismiss this line.                 foreach ($_FILES as $file => $array) {                     $newupload = insert_attachment($file);                     var_dump($file);                 }             }         }     }      insert_attachment function:               function insert_attachment($file_handler) {            // check to make sure its a successful upload       if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();            require_once(ABSPATH . "wp-admin" . '/includes/image.php');       require_once(ABSPATH . "wp-admin" . '/includes/file.php');       require_once(ABSPATH . "wp-admin" . '/includes/media.php');            $attach_id = media_handle_upload( $file_handler, 0 );     }      Can anyone assist me? :) **EDIT: Here is the code that was used to correctly insert_attachment**               function udev_before_uploader() {      if ( !empty($_FILES) ) {         $files = $_FILES;         foreach($files as $file) {             $newfile = array (                 'name' => $file['name'],                 'type' => $file['type'],                 'tmp_name' => $file['tmp_name'],                 'error' => $file['error'],                 'size' => $file['size']             );                  $_FILES = array('upload'=>$newfile);             foreach($_FILES as $file => $array) {                 $newupload = insert_attachment($file);             }         }     }                    }


title: How to set the default value as the saved value once a form of widget is saved?

text:
I tried doing this for the function form :               <?php     function form(){              //Set up some default widget settings.              $defaults = array( 'uid' => __('121232', 'example'), 'height' => __('250px', 'example'), 'width' => __('170px', 'example') );            $instance = wp_parse_args( (array) $instance, $defaults );          ?>
             <label for="<?php echo $this->get_field_id( 'uid' ); ?>"><?php _e('User ID:', 'example'); ?>             <input id="<?php echo $this->get_field_id( 'uid' ); ?>" name="<?php echo $this->get_field_name( 'uid' ); ?>" value="<?php echo $instance['uid']; ?>" style="width:100%;" />

             <label for="<?php echo $this->get_field_id( 'height' ); ?>"><?php _e('Height:', 'example'); ?>             <input id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" value="<?php echo $instance['height']; ?>" style="width:100%;" />

             <label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php _e('Width:', 'example'); ?>             <input id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" value="<?php echo $instance['width']; ?>" style="width:100%;" />
              <?php     }              ?>      I can use the default values as I have given, but after clicking the on save button with some other values in form, it returns into the previous default values. In the front-end, the widget is working fine along with the values I have chosen manually, but in the admin panel, the form is showing the default values as it's in the code.


title: Extending auth_cookie_expiration based on user role

text: I'm trying to extend the lifespan of the authentication cookie, but only for administrators. My code in functions.php is:               add_filter( 'auth_cookie_expiration', 'change_admin_cookie_logout' );     function change_admin_cookie_logout( $expirein ) {         if ($user_id == current_user_can('promote_users')) {           return 60;  // yes, I know this is 1 minute         } return 20;     }      The problem I'm having is twofold:   1. When I leave off the else statement, then login fails. In other words, I seem to have to define the expiration time for admins & non-admins, rather than singularly modifying the admin expiration time.   2. the above formula ignores "remember me" and applies it globally. I'd like it to apply only when "Remember Me" is checked. I've tried tweaking wp_set_auth_cookie but hit some walls and came back to this method. Any help is greatly appreciated!


title: How do I display two separate taxonomy archives for two post types that share a single taxonomy?

text: I have a custom content type, "products", which shares the category taxonomy with posts. We're using posts to discuss and review products. The idea is to have two separate URLs:   * /discussion/category/term/ : Displays a listing of posts belonging to a specific term with a "related products" area pulling from the same term   * /products/category/term/ : Displays a listing of products belonging to that term with a "related discussions" area pulling from the same term I can use the default category/archive templates with a permalink front for posts, and the first is solved by default. But since each taxonomy only has one template set, how can I achieve the second? The above URLs are examples, and all archive types would ideally work with the normal permalink structures after the initial front/slug. Looking at similar questions, I've seen suggestions to use two different taxonomies with the same terms, but as of WordPress 3.7 terms of two different taxonomies can no longer share a slug, so relating the two is problematic for a non-technical site manager. I also know how to use get_query_var('post_type') to differentiate the two post types, but that doesn't solve the issue of separate URLs. Any help is greatly appreciated!


title: Create WordPress posts from JSON array using plugin in admin

text: I'm writing a WordPress plugin that I'd like to do the following:   1. Add a WordPress plugin admin page that contains a button   2. When you click the button, it loads an array of JSON objects from a file, then creates a WordPress post for each object I got #1 done, and I can see the array of JSON objects loading upon button click since I use `console.log`. (I made the button using this tutorial \- uses AJAX.) But, how would I go about giving WordPress access to the JSON array so I can create posts using `wp_insert_posts`? Is this even possible?


title: Widget Logic - Target 1 URL

text: TestSite.com/?property=Name How do I target only this URL with conditional tags and widget logic. I've tried is_singular( 'Name' ), but that didn't work.


title: Searchform for searching specific categories

text: <form id="searchform" method="get" action="<?php echo home_url(); ?>">     <input type="text" name="s" id="s" size="15" />     <?php wp_dropdown_categories( 'show_option_none=Select' ); ?>     <input type="submit" value="Search" />     </form>      This snippet gives me a searchbox with a selectbox in which I can choose which category I want to search in. That's nice, but **I don't want to show it ALL categories that I have, no, I want to show it specific categories.** How can I do this? Is that even possible?


title: Using variable to display a page with a different stylesheet

text: Is it possible to implement a different stylesheet for a page using a url variable, for example **Normal URL: www.example.com/page** Would use the normal stylesheet **Alternative URL: www.example.com/page?=alt** Would use an alternative stylesheet


title: Accidentally changed the url

text: I happened to accidentally change the url from my website ... I have read a so many articles about what to do and I understand that I probably need to change something from a database, and that it is easiest to do through phpmyadmin, but when I get there it looks nothing like the guides i've been watching. I can't find anywhere I can log in, but it seems that I should download it ... so then I did it and it felt like it seemed more like a strange search tool ... I do not understand, someone please help me!!


title: Is there a reason I cannot get the current category in a loop?

text: I think I am doing this wrong but if I do:               if(have_posts()){         $category_id = get_query_var('cat');     var_dump($category_id);         while (have_posts()){             the_post();         }     }      the var dump comes back empty. Why? Is there a better way to get the current category object in a loop? the same question applies to tags. Can I also get the current tag object if this was a `is_tag()`?


title: Custom Page Template not working when site moved from subfolder

text: I have been testing and redesigning my site in a subfolder: http://theseattlevine.com/wordpress2013 Today I am launching the site and have followed these instructions (http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory) to make the subfolder display as the main site. I have done this many times before without issue. Everything seems to be working fine except for one of my page templates. If you go to the new site, now at http://theseattlevine.com the "Publish" button from the main nav is throwing a 404 error. I have that page set up to use a custom template called "publishing center" but for some reason it is not working on the new setup (it worked fine before). I have tried resetting permalinks as well as completely deleting the .htaccess file and then re-saving permalinks, and it's still not working. All of my posts and other pages seem to work fine. I can't figure out what's wrong, can anyone give some insight?


title: Custom Post Type Taxonomy Filters

text: Im really struggling to piece this functionality together, and hope someone can help or provide snippets to get me there. So I'm creating a section on a website where stories are published, I have created a custom post type for the stories section and taxonomies for the story types (category) and story tags (the tags). Everything is working fine and displaying correctly in that respect. Heres the setup details:   * Custom Post Type: stories   * Custom Taxonomy (the category): story-type   * Custom Taxonomy (the tags): story-tags I need to be able to filter posts on a landing page by 4x options:   * Story Type Taxonomy (Chapter or Extract, Featured, Flash Fiction, Micro Fiction, Poem, Short Story)   * Story Tags Taxonomy (Debut, Funny, True Story)   * by Month (jan, feb, march, etc…)   * Sort by (most read, most recent) So an example: Please show me all Fiction stories tagged funny in June and sort them by most read. I'm not fussy where the results are displayed as long as they are accurate. The results page would then be titled "Your Results" Thanks for your time so far...


title: How to Set Limit with WordPress Get Bookmarks Shortcode

text:
I just need some help with a WordPress shortcode function. I would like to create a list of links based on the link_category inside a post with a shortcode. I had the shortcode working until I added the limit argument to the function. So Basically can someone help me correct this problem? The code can be seen below, as copied from my functions.php file. Please note that I am no php expert, but I can edit/break existing code like a champ. The site in question is http://linuxlibrary.org I appreciate the help!               add_shortcode('lynx', 'lynx_shortcode_handler');          function lynx_shortcode_handler($atts)     {         // extract parameters         $parms = shortcode_atts(array(             'cat_name' => 'Learn More',             'limit' => '5',             'use_description' => 'false',             'use_image' => 'false',             'before_line' => '
',             'after_line' => '
     ',             'before_content' => '
     ',             'after_content' => '
     ',             'target' => '',             'xfn' => '',             ), $atts);              $cat_name = $parms['cat_name'];         $use_description = strtolower($parms['use_description']);         $limit = $parms['limit'];         $use_image = strtolower($parms['use_image']);         $before_line = $parms['before_line'];         $after_line = $parms['after_line'];         $before_content = $parms['before_content'];         $after_content = $parms['after_content'];         $target = $parms['target'];         $xfn = $parms['xfn'];              // process t/f options         $b_use_description = false;         if (($use_description == 'yes') || ($use_description == 'y') ||             ($use_description == 'true') || ($use_description == '1'))         {$b_use_description = true;}              $b_use_image = false;         if (($use_image == 'yes') || ($use_image == 'y') ||             ($use_image == 'true') || ($use_image == '1'))         {$b_use_image = true;}              // exit         return lynx($cat_name, $b_use_description,             $b_use_image, $before_line,             $after_line, $before_content,             $after_content, $target, $xfn);          }               }          function lynx(         $cat_name='Learn More',         $limit='5',         $use_description='1',         $use_image='1',         $before_line='
',         $after_line='
     ',         $before_content='
     ',         $after_content='
     ',         $target='',         $xfn='')     {              // get the data         $args = array('limit' => $limit,                 'orderby' => 'rating',                 'order' => 'DESC',                 'category_name' => $cat_name);         $bookmarks = get_bookmarks($args);              // process the data         $output = $before_content;         foreach ($bookmarks as $bmk)         {             $bmk_link = $bmk->link_url;             $bmk_name = $bmk->link_name;             $bmk_description = $bmk->link_description;             $bmk_image = $bmk->link_image; // works best with icons (like favicon.ico)             $href = '' . $bmk_name . '';                  $output .= $before_line;             if ($use_image == '1')             {                 // assumes 16x16 icons and aligns margin accordingly                 // MSIE has issues with some favicon.ico files                 $output .= ' ';             }             $output .= $href;             if ($use_description == '1')             {                 $output .= ' ' . $bmk_description;             }             $output .= $after_line;         }              // exit         $output = $output . $after_content;         return $output;     }


title: Creating two loops based on different logic

text: I'm trying to figure out the best way to go about this and I have part of my solution, but I can't figure out all of it. My ultimate goal is within a certain page template, to show the newest post from a CPT of a particular taxonomy, this seems to be the easiest and accomplished with this:               $args=array(         'post_type' => 'portfolio',         'post_status' => 'publish',         'orderby' => 'date',         'order' => 'DESC',         'posts_per_page' => 1,         'type' => 'featured'     );          $portfolio_query = new WP_Query($args);      The next part would be show all of other posts, with the exception of the post that is queried above. Can this be done with a single loop, or will I need multiple loops with offset logic? I'm lost on how to accomplish this. TIA.


title: INSERTING Data into table with placeholders

text: I am trying to insert data into a table, getting errors, I have tried messaging the data, but cannot seem to get it to work, can you please help me figure out what I did wrong, please... Here is my code I execute after validation is done:                                  $sql = 'INSERT INTO `tablename` (`file`,`afile`,`type`,`keyword`,`location`,`numbl`,`userul`,`uldate`) values (%s,%s,%s,%s,%s,%s,%s,%d) "'. $_REQUEST['filename'] . '", "' . $url . '", "' . $_REQUEST['filetype'] . '", "' . $_REQUEST['filekeyword'] . '", "' . $_REQUEST['filelocation'] . '", "' . $_REQUEST['filenumbl'] . '", "' . $user_login . '", "' . time() . '"';                         $wpdb->query($sql);                         $_tbInsertId = $wpdb->insert_id;      It is not working. I added the show errors code and it says this:                 WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s,%s,%s,%s,%s,%s,%s,%d) "LK-Contractor-NOGglRev-16Ld-082214.csv"' at line 1]      I even tried putting a comma AFTER the closing ) in values... but same error. I added "quote" marks around all of the fields, that did not fix it either. Do you see what is causing it? Thanks, Richard


title: Rewrite Rules Are Redirecting and Not Passing VARs

text: I have the following code in my functions.php file.               <?php     add_action('init', 'flush_rewrite_rules');          function custom_add_rewrite_rules( $wp_rewrite ) {         $new_rules = array(              'insurance-leads-types/auto-insurance-leads/([^/\.]+)/?$' => 'index.php?pagename=auto-insurance-leads&state=' . $wp_rewrite->preg_index(1),             'insurance-leads-types/home-insurance-leads/([^/\.]+)/?$' => 'index.php?pagename=home-insurance-leads&state=' . $wp_rewrite->preg_index(1)         );         $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;     }     add_action('generate_rewrite_rules', 'custom_add_rewrite_rules');          function add_query_vars( $query_vars ) {       $query_vars[] = 'state';       return $query_vars;     }     add_filter( 'query_vars', 'add_query_vars' );       When I go to the page /insurance-leads-types/auto-insurance-leads/STATENAME/ the URL is redirected to /insurance-leads-types/auto-insurance-leads/ without the trailing STATENAME/ and the variable is not passed to $query_vars. I used Monkeyman's Rewrite Analyzer and everything looks fine: pagename: auto-insurance-leads state: (.[^/]+) Any ideas why the URL is redirecting?


title: If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?

text: One custom post type that i've created has 5 custom fields that display specific content for a template that displays them in different areas on the page. My question is if i would have to create another loop for each custom field i'm referencing on my template or if one would suffice? Thanks.


title: Woocommerce - Get product category 2nd level category

text: I have 3 levels deep product categories like following : A   |--B   |---C I want to get B, but don't know how to do. I can get all product categories, but don't know how to filter out. Here the code I use to get product categories : ID, 'product_cat' );                           foreach( $product_category as $cat ):                 if( 0 == $cat->parent )                     echo $cat->name;                 endforeach;


title: Results not being printed

text: I am trying to run the following code, which i got from the site but i don't see any output.When i do `print_r($product)` only then i get array back.               $args = array(           'post_type' => 'product',            'posts_per_page' => 4       );       $featured_query = new WP_Query( $args );           if ($featured_query->have_posts()) :            while ($featured_query->have_posts()) :                $featured_query->the_post();               $product = get_product( $featured_query->post->ID );               echo $product;         endwhile;          endif;


title: Mapping external data to tags via term_id

text: I'm looking at migrating a custom CMS with about 40k posts and about 100k tags into WP. The site covers news about the concert industry and will use tags as artist names associated with each post. There will be external APIs to pull in proprietary images and tour dates for each artist, and they'll need to map to a term_id for the tag which will be the artist name. Internally, a lookup table will need to map against the term_id to generate the API hooks and commerce links. The question is whether a taxonomy within WP--mapping a tag to several columns of associated content hooks--is the best way to come at this, or should this become an external tag-mapping plugin that works outside the WP table structure from the outset.


title: I broke database after reuploading local version - what exactly happened? Database error

text: The site was already working but since I wanted to change the website more and my Internet is not good right now, I decided to download the whole wp folder to local drive, and export database. I set up xampp, all went well. Then I was editing and I put it back like this: 1) first I renamed the wp folder to wp_old, and uploaded the new one; 2) then I tried to import the db in phpmyadmin but it didn't let me (something something already exists) - so I renamed the old DB to db_old and imported the new one. I changed the values that referred to 127.0.0.1 to mywebsite.com (home and url) but now if I go to website: Error establishing a database connection and wp-admin gives me: Can’t select database We were able to connect to the database server (which means your username and password is okay) but not able to select the _*_ *_* database. Any idea? Thanks in advance for any feedback I will be really grateful if you take the time to help me In phpmyadmin the situation looks strange ... http://i.imgur.com/IxE4tU2.png \- why do the dbs "stack" like that?


title: URL with without www shows just a blank page

text: i have a little problem with my wordpress page... when I enter the URL with www, the page is shown the right way. But when I enter it without www, then it shows just a blank page and the source code just shows the html, head and body tag... www.blumengalerie.ch / Also the page displays this white page when I enter a subpage without the backslash at the end (www.blumengalerie.ch/kontakt/) I called my hoster and he assured me, the both (www/no www) are assigned to the same path... I've updated the permalinks and the .htaccess file shows only the entry for the permalinks...               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      Dows anyone know what the problem could be? I could really use some help Thanks Alex


title: loss of theme options while site deployment in production

text: i have moved both wordpress folder and the development database on a distant server. Why all my theme options are lost ? where are these options stored if not in wp_options table nor wp_files ?


title: jQuery autocomplete: retrieving term slug when term name selected

text:
I'm trying to set up a customized searchform that will allow the visitor to search posts linked to term(s) of several taxonomies. The autocomplete part seems to work fine, but I've no idea how to get the term slug so I can build the query string once the visitor has selected the term name. Here is the HTML:                   <fieldset>
             Collections :              <input id="collection">

             Sujets :              <input id="sujet">

             Lieux :              <input id="lieu">

             Mots-clés :              <input id="tag_perso">
          </fieldset>      The Javascript:               jQuery(function() {          jQuery( "#collection" ).autocomplete({ source: availableTags.collection });     jQuery( "#sujet" ).autocomplete({ source: availableTags.sujet });     jQuery( "#lieu" ).autocomplete({ source: availableTags.lieu });     jQuery( "#tag_perso" ).autocomplete({ source: availableTags.tag_perso });      and the PHP:               function get_autocomplete_source($taxonomy) {     $args = array(         'hide_empty'    => 0,         'fields'        => 'all',     );     $term_objects = get_terms($taxonomy, $args);     $terms = array();     foreach ($term_objects as $term_object)      {         $return_object = new stdClass;         $return_object->value = $term_object->name;         $return_object->slug = $term_object->slug;         $terms[] = $return_object;     }     return $terms;}      the script having been localized this way:               wp_localize_script('cevennes_autocomplete', 'availableTags', array(     'collection'    => get_autocomplete_source('1-collection'),     'sujet'         => get_autocomplete_source('2-sujet'),     'lieu'          => get_autocomplete_source('3-lieu'),     'tag_perso'     => get_autocomplete_source('4-tag_perso')     ));      I'm a bit lost with Javascript. Could someone help? Thanks a lot.