Show top-level parent with submenu menu walker

I've used the menu walker below to display dynamic submenus with great effect in the past. It displays 2nd- or lower-level menu items IF the current page is a parent, sibling, or descendant of the page. For example if the menu hierarchy is:   * a   * b      * 1        * i       * ii It will show, 1, i, and ii if on pages B, 1, i, or ii. What I want to do is add the parent item (B in the example) to that so that the top-level parent also appears. I've read up on walkers, tried to make sense of this code, but am still stuck even on where to begin.               // Show only the child pages of a menu     class child_menu_walker extends Walker_Nav_Menu {         var $found_parents = array();              function start_el(&$output, $item, $depth, $args) {             global $wp_query;                  if( $wp_query->is_single && !in_array( get_option('page_for_posts'), $this->found_parents ) ) {                 $this->found_parents[] = get_option('page_for_posts');             }                  //this only works for second level sub navigations             $parent_item_id = 0;                  $indent = ($depth) ? str_repeat("\t", $depth) : '';                  $class_names = '';             $classes = empty($item->classes) ? array() : (array) $item->classes;             $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));             $class_names = ' class="'.esc_attr($class_names).'"';                  #current_page_item             // Checks if the current element is in the current selection             if(                 strpos($class_names, 'current-menu-item') ||                  strpos($class_names, 'current-menu-parent') ||                  strpos($class_names, 'current-menu-ancestor') ||                  ( is_array($this->found_parents) &&                      in_array($item->menu_item_parent, $this->found_parents) )             ) {                 // Keep track of all selected parents                 $this->found_parents[] = $item->ID;                 //check if the item_parent matches the current item_parent                 $item_output = '';                 if ($item->menu_item_parent != $parent_item_id ) {                     $output .= $indent.'
';                          $attributes = !empty($item->attr_title) ? ' title="'.esc_attr($item->attr_title).'"' : '';                     $attributes .= !empty($item->target) ? ' target="'.esc_attr($item->target).'"' : '';                     $attributes .= !empty($item->xfn) ? ' rel="'.esc_attr($item->xfn).'"' : '';                     $attributes .= !empty($item->url) ? ' href="'.esc_attr($item->url).'"' : '';                          $item_output = $args->before;                     $item_output .= '';                     $item_output .= $args->link_before.apply_filters('the_title', $item->title, $item->ID).$args->link_after;                     $item_output .= '';                     $item_output .= $args->after;                 }                 $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);             }         }              function end_el(&$output, $item, $depth) {             $parent_item_id = 0;                  $class_names = '';             $classes = empty($item->classes) ? array() : (array) $item->classes;             $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));             $class_names = ' class="'.esc_attr($class_names).'"';                  if(                 strpos($class_names, 'current-menu-item') ||                  strpos($class_names, 'current-menu-parent') ||                  strpos($class_names, 'current-menu-ancestor') ||                  (is_array($this->found_parents) &&                      in_array($item->menu_item_parent, $this->found_parents))             ) {                 // Closes only the opened li                 if (is_array($this->found_parents) && in_array($item->ID, $this->found_parents) && $item->menu_item_parent != $parent_item_id) {                     $output .= "
\n";                 }             }         }              function end_lvl(&$output, $depth) {             $indent = str_repeat("\t", $depth);             // If the sub-menu is empty, strip the opening tag, else closes it             if (substr($output, -22) == "
\n") {                 $output = substr($output, 0, strlen($output) - 23);             } else {                 $output .= "$indent
\n";             }         }     }


Taxonomy in URL

I have a huge problem: I want to have nice URL's on my Homepage. I got a custom post type and taxonomies. Now I want to have a URL like that: > www. mydomain .com/videos(Category)/funny(Taxonomy)/the-video(Post) or > www. mydomain .com/videos(Category)/sport(Taxonomy)/the-video(Post) How do I get this? I am searching for about a year now...


Multisite wordpress config on multidomain

I have to create multisite on wordpress network. maindomain.com its base for all, but it only crossroad for users. Links from maindomain.com redirect to domain1.com, domain2.com and domain3.com for this tree domain i need to make wordpress network. The biggest question is, how can i do that? All of this domain will be on the same server. Any ideas for help mi with?


Calling a plugin in theme development

I am trying to call plugins on a theme page. Specifically I am after the 'User Avatar' theme but their will be other later. How do I call a plugin on a theme? Presumable something linke `<?php` ...plugin name... `;?>` but that isn't it. Any ideas. Marvellous


How to modify template tags function

By default, get_user_meta returns an array, a single value or false. I want to change the return value somehow. How to do that? I want to modify the return type of a template tag get_user_meta inside the class only. How to do this? I am trying this:-               class modifyUserMeta {         function modifyUserMeta(){             add_filter('get_user_meta',$this->modifyMeta);         }         function modifyMeta(){         //how can i modify the return type of get_user_meta?         }     }


How to display login form anywhere, when user isn't logged in, without redirecting?

I'm currently using Theme My Login, and I'm building a membership website where nothing is accessible to anyone, unless they're logged in. When a user, who isn't logged in, enters anywhere on the site, they should be prompted with the _Theme My Login_ login form, which essentially is designed as an individual page. How do I get rid of the URL extension (www.example.com/login), which is where the user normally would be redirected to, and simply just showing the page template no matter where the user enters the website (e.g. _/about_ , _/contact_ , etc.), when he/she isn't logged in?


Ajax category pagination problem

I want to make a pagination or load more button for my ajax category display. Here is my attempt, I have no idea how it can work out. Any ideas?               add_action( 'wp_ajax_nopriv_load-filter', 'prefix_load_cat_posts' );      add_action( 'wp_ajax_load-filter', 'prefix_load_cat_posts' );               /*main function of fetching the category selected*/     function prefix_load_cat_posts () {     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $temp = $DamonQuery;     $DamonQuery= null;     $DamonQuery = new WP_Query();          $cat_id = $_POST[ 'cat' ];     $args = array (         'cat' => $cat_id,         'posts_per_page' => 10,         'orderby' => rand,         'post__not_in' => $do_not_duplicate,         'paged' => $paged,         'order' => 'DESC'     );          $total = 14;          $thumbnailno = array();          for($x=0;$x<$total;$x++) {         $thumbnailno[$x] = "http://www.chandamon.com/home/wp-content/uploads/nothumb" . $x . ".png";     }          $DamonQuery->query($args);          $max_page = $DamonQuery->max_num_pages;          ob_start ();          if ( $DamonQuery->have_posts() ) {         while ( $DamonQuery->have_posts() ) {             $DamonQuery->the_post();             if ( has_post_thumbnail( $DamonQuery->post->ID ) ) {                 $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),      'large');                 echo '
ID . '" title="' . the_title_attribute('echo=0') . '" >';                 echo get_the_post_thumbnail($post->ID, 'array(255,255)');                 echo '
';             }             else {                 echo  '
' . '';                 echo  '
';             }         }            /*pagination here*/              $big = 999999999;               echo paginate_links( array(             'format' => '#',             'current' => max( 1, get_query_var('paged') ),             'total' => $DamonQuery->max_num_pages          ) );                      wp_reset_postdata();              $DamonQuery= null;         $DamonQuery= $temp;     }          echo '
';          $response = ob_get_contents();     ob_end_clean();          echo $response;     die(1);     }


How to disable pagination on a gallery template?

With the pagination activated in the Options panel and when using different gallery templates, is there a way to disable pagination on a specified template? If I have more than one gallery on a page, and have pagination turned on for the thumbnails, then the pagination on one gallery also controls the pagination on the other galleries on the page Any idea? Thanks


Send batch of posts as HTML Email?

Looking for a little help getting to grips with a quote, part of which is producing quarterly reports consisting on all the posts from that quarter. My question is two fold - Is there a plugin that can do this sort of thing? Or of not, any clue as to where to start coding it? Cheers


Completely replacing the login form

I need to completely replace WP's login form with the login form of an external service. The actions and filters I've found (eg login_form, login_head) seem to rely on WP's login process starting. I suppose I could do a redirect from here, but is there a cleaner way of sending a user to another URL if they attempt to browse to a WordPress login page.


Is it still not possible to show separate submenu with "Custom Menu"?

Well, the title says it all. Is it still not possible to show separate submenu with the "WP Custom Menu"?


Hide Admin menus per role in Wordpress

I am trying to hide a certain amount of menus for a client. Right now I am using the following code and it is doing its job well, but it removes it for everyone as far as I can tell. As in all roles.               function remove_menus () {     global $menu;         $restricted = array(__('Dashboard'), __('Media'), __('Links'),      __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Profile'),__('Plugins'));         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');      What is the line I would use to have this call out only an editor or an author etc? Thanks much


How do I dequeue a parent theme css file?

My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php:               add_action( 'wp_enqueue_scripts', 'script_enqueuer' );          function script_enqueuer() {         wp_register_script( 'site', get_template_directory_uri().'/js/site.js', array( 'jquery' ) );         wp_enqueue_script( 'site' );              wp_register_style( 'screen', get_template_directory_uri().'/style.css', '', '', 'screen' );         wp_enqueue_style( 'screen' );     }      I've tried the following in the child functions.php, but the link and script tags still show up in the head section.               add_action('init', 'removeScripts');     function removeScripts() {         wp_dequeue_style('screen');         wp_deregister_script('site');     }      I've double checked to see if they are hard coded in the parent header and they are not. Thanks for the help!


What are the benefits of using wp_enqueue_script?

Is there any real benefit to using wp_enqueue_script on small self-managed sites? For instance, Modernizr, why enqueue it through a function rather than call it directly inside the document head? I can see the benefit on large sites, where you may move around directories or have multiple people mucking around in the files, or in a publicly available theme with numerous unknowns, but what's the benefit on a small site like a personal blog that never - or rarely - changes and has a single user? It just seems like extra lines of code in that case.


Insert custom postmeta when custom post type published

I'm trying to populate the postmeta table with a custom value when a custom type ('my-solutions') is published. I've read a few threads, the Codex and Pippin's blog on this matter and tried many variations, but can't get this to work. If anyone can add or correct anything that would be great.               function run_when_my_solution_published( $post ){         global $wpdb;         $id = $post->ID;         if($post->post_type == 'my-solutions'){             $wpdb->insert('wp_postmeta', array( 'meta_id'     => NULL       ,                                                 'post_id'     => $id        ,                                                 'meta_key'    => 'my_json'  ,                                                 'meta_value'  => 'json'     ),                                          array( '%d' , '%d' , '%s' , '%s' )             );                   }     }     add_action('new_to_publish', 'run_when_my_solution_published');


How to Insert Shortcodes into Theme?

I have content locker plugin. For locking contents, im using this shortcode: **[wp-like-locker]** Your locked content here... **[/wp-like-locker]** and I need lock every post on my blog. How could I instert this shortcodes into theme and lock: **Thank you very very very much for your answer and time!**


Create a custom admin page for custom post type + taxonomies + metas

I'm writing a plugin that realies on custom post types, new taxonomy and few custom fields. All this data will be private (not queryable or searchable). I'd like to provide an admin page to the user, to add and edit this data in a more suer-friendly way. For instance, the custom post type will have only a title and the excerpt field, one taxonomy and the custom fields. I know how to add meta boxes to a custom post type, but this is not enough to me. I'd like to make a completely custom html interface that will take care of adding/saving/deleting che custom post type and handle the taxonomy and metas. Just to be clear, I know already ho to write a normal plugin and handle plugin's options. I don't know how, with this plugin I can:   * Add a new menu item in Wordpress admin menu   * In this menu item, handle, _with a custom interface_ , the custom post type There is some how-to out there that could help me achieving this?


Custom search function not finding posts with tax terms even thought the association exists

I have a custom hierarchical taxonomy called "destination_category" with terms like so: Cultural   * Museum   * Historic I have a custom post type with posts associated with all three "Cultural" (parent), "Museum" (child), "Historic" (child). When my custom search function searches for posts with "Museum" and "Historic", it works and includes the post. However, when I include the parent term "Cultural". The post is NOT returned. So, it seems that my query is ignoring the fact that my post is associated with the parent term "Cultural", and it has something to do with it being a parent term. Here is what my search function looks like:               function advanced_search_query($query) {          if($query->is_search()) {              $query->set('post_type', 'destinations');              // tag search         if (isset($_GET['termlist']) && is_array($_GET['termlist'])) {             $tax_query_args = array(                 array(                     'taxonomy' => 'destination_category',                     'field' => 'slug',                     'terms' => $_GET['termlist'],                     'operator' => 'AND'                 )             );                  $query->set('tax_query', $tax_query_args);         }              return $query;     }      }


W3C validation errors (trailing slashes)

My site is throwing up a few errors typically due to trailing slashes being added. eg. wordpress is adding in:               <meta name='robots' content='noindex,nofollow' />      my doctype is:               <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">      If my understanding is correct the validator is seeing those trailing slashes as being xhtml but is getting worried as the doc type doesn't state it. I don't want it to be an xhtml doctype as that causes me lots of other problems. My code is fine but its bits like that meta tag that wordpress is putting in that is causing the problem. How do I solve this? the trailing slash is making the validator think things are closing so its then throwing up errors on stupid stuff like my closing head and opening body tags.


custom taxonomies label in hebrew

I'm trying to add a custom taxonomy. using the following code:                   function cities_custom_taxonomies() {         register_taxonomy(             'city', // internal name = machine-readable taxonomy name             'post', // object type = post, page, link, or custom post-type             array(                 'hierarchical' => false, // true for hierarchical like cats, false for flat like tags                 'label' => 'City', // the human-readable taxonomy name                 'query_var' => true, // enable taxonomy-specific querying                 'rewrite' => true // pretty permalinks for your taxonomy?             )         );     }     add_action('init', 'cities_custom_taxonomies', 0);      As long as I use label name in English, all works fine. Once I try to label it in Hebrew, I don't see the new taxonomy menu. any Idea ?


How can you develop on a live WordPress installation that is using W3 Total Cache?

Or to make it easier: you just want to disable the caching in order to see your changes in realtime. Any solution that would allow you to disable caching based on IP, logged user or cookie will be acceptable.


Change page template programmatically ?

I have two page templates and Qtranslate installed. I want to choose one or another depending the language selected. Can I do something like this ?               if($q_config['lang'] == 'en'){     // load page-template_en.php     }else{     // load page-template_de.php     }      Any idea ? Thanks!


Contributor disable seeing others' posts

How can I disallow contributors on my site from seeing what other posts are published on the site, and only see their own?


Defer Parsing of Scripts

this is my first time to try this "Defer Parsing" thing, and I don't really have an idea how to do it. ![enter image description here](http://i.stack.imgur.com/4fJnH.jpg) Using PageSpeed tool, I found out that one of the reason why my page is loading too slow (currently 92/100) are the scripts. And the PageSpeed suggested that I need to Defer Parsing all those scripts. Is there anyone that can help me with this. Thanks.


Translated my theme (translation not showing up)

I read a lot about what is the optimal to translate your website (french and english in my case) I set up a Multi site where I created two site one french mywebsite.com/fr and one in english mywebsite.com/en I am now in the process of translating my theme(in french by default) I added this to my theme function.php:               load_theme_textdomain('INTERluminaires', get_template_directory() . '/languages');      then modified my template files in order to be able to translate some text               <?php _e("Design et conseils", "INTERluminaires"); ?>      created a po and mo file with poedit, everything goes well. I uploaded those files in my theme folder /languages those files are named en_CA.po and en_CA.mo (I tried INTERluminaires-en_ca.po and mo to no avail) when I change my theme language in settings general and refresh my website nothing is translated. any idea what could be wrong here? btw I managed to translate a plugin I installed without any problem.


I am trying to grab the title and put it in a paypal form select option

I am trying insert the title of a post in the option value of a form for paypal purchase, so I know what item they have chosen. But when I do this paypal gives me a error message that something is wrong with my site. Am I doing this wrong I am trying to insert the title of a post in a option value below.               <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">     <input type="hidden" name="cmd" value="_cart">     <input type="hidden" name="business" value="7MNYTPNDKMZS6">     <input type="hidden" name="lc" value="CA">     <input type="hidden" name="item_name" value="Tshirt">     <input type="hidden" name="button_subtype" value="products">     <input type="hidden" name="tax_rate" value="0.000">     <input type="hidden" name="shipping" value="0.00">     <input type="hidden" name="add" value="1">     <input type="hidden" name="bn" value="PP-ShopCartBF:cart.png:NonHosted">

<input type="hidden" name="on0" value="Tshirt">Tshirt

<select name="os0">         <option value="<?php the_title();?>">Deer $20.00 CAD</option>     </select>

<input type="hidden" name="on1" value="sex">sex

<select name="os1">         <option value="female">female </option>         <option value="male">male </option>     </select>

<input type="hidden" name="on2" value="T-shirt Style">T-shirt Style

<select name="os2">         <option value="Crew">Crew </option>         <option value="V-neck">V-neck </option>         <option value="Deep-V">Deep-V </option>         <option value="Tank">Tank </option>     </select>

<input type="hidden" name="on3" value="T-shirt size">T-shirt size

<select name="os3">         <option value="XS">XS </option>         <option value="S">S </option>         <option value="M">M </option>         <option value="L">L </option>         <option value="XL">XL </option>     </select>

<input type="hidden" name="on4" value="Effect">Effect

<select name="os4">         <option value="faded">faded </option>         <option value="rainbow">rainbow </option>         <option value="gradient">gradient </option>         <option value="glow">glow </option>     </select>

<input type="hidden" name="on5" value="T-shirt colour">T-shirt colour

<input type="text" name="os5" maxlength="200">

<input type="hidden" name="on6" value="Design Colour">Design Colour

<input type="text" name="os6" maxlength="200">

     <input type="hidden" name="currency_code" value="CAD">     <input type="hidden" name="option_select0" value="Deer">     <input type="hidden" name="option_amount0" value="20.00">     <input type="hidden" name="option_index" value="0">     <input type="image" src="http://goodmorningmoon.ca/wp-content/themes/Good-Morning-Moon/images/cart.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">          </form>


Custom post type pagination 404 fix?

Been trying to get this working all day but haven't had any luck... I have a custom post type called 'news' and an archive template (archive- news.php), here I'd like to show 2 posts with pagination, which works fine, until I try to go to the 'next page' (/news/page/2) which returns an error 404. Any idea how to fix this / what I'm doing wrong? I've literally spent all day trying to find a solution to this by searching Google and the WordPress forms, I found lots of solutions, none of which have worked so far. My custom post type function: http://pastebin.com/uG1L6YNu   My rewrite rules print: http://pastebin.com/jbaDANYr


show list of latest comments for each post in a loop

I want to show the last 5 comments for each post on my index page loop of posts. What Im using now is only showing the same comments for every post. How should I set this up and how can I add an avatar to each comment. What have this obviously isn't working..               <?php       $args = array(     'status' => 'approved',     'number' => '5',        );       $comments = get_comments($args);         foreach($comments as $comment) :       echo( $comment->get_avatar . $comment->comment_author . '<br />' . $comment->comment_content);        endforeach;      ?>


How to show multiple images in a slideshow for a portfolio page

I am planning to build a portfolio using custom post types, so the main portfolio page will show a "featured" image for each portfolio post. Once you click on one of these images you will go to the actual post page for that portfolio item. Once on this page I would like to show multiple images for this particular portfolio post. So I am thinking of doing some sort of slideshow or possibly a big image with little thumbnail images that when clicked will load the larger version of the image into the big image slot. So I am curious, when making a post for a portfolio item, how would I go about uploading and integrating multiple images for each item? See the bottom of my mockup below, when you click on a thumbnail for a particular portfolio item, it will load a larger image ![enter image description here](http://i.stack.imgur.com/LRuQu.png)


Uncaught TypeError: undefined is not a function (shortcode-box)

I have a Wordpress theme that the author is no longer maintaining, and has stopped functioning properly with the update to Wordpress 3.x. Over the past few months, I have been working to resolve the issues with the theme. Most of these issues have been related to JavaScript, and I have been able to fix most of them. I'm finally down to one I can't fix: This theme contains a function in the admin panel to add new shortcodes that a user can create and performs all the steps correctly except the last: send the shortcode to wordpress editor. Chrome inspect gives me this error: > Uncaught TypeError: undefined is not a function --- shortcode-box.js:1305 > > shortcode.sendToEditor --- shortcode-box.js:1305 > > (anonymous function) --- shortcode-box.js:16 The lines referred to by the errors: line 1305               sendToEditor :function(){             window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, shortcode.generate());         }      line 16               jQuery('#shortcode_send').click(function(){                 shortcode.sendToEditor();             });      I attached the shortcode-box.js file: http://www.samuguerra.com/shortcode- box.js Can anyone help me? Excuse my English, as I wrote this with the help of Google Translate


Activating a Theme Options page to Editor - not working

I used Ian Stewart's Simple WordPress Theme Options Page (Source^) for my client's site, where I assigned my client as an Editor. But from the Editor account the **Theme Options** link is not visible. I checked the `theme-options.php` for `add_theme_page()`, where it's used `'edit_theme_options'` as the menu's capability. But unfortunately it's not visible. I installed:   * User Role Editor, and   * White Label CMS But in White Label CMS, I unchecked the hide menu thing. But the link becomes visible only if I check the User Role Editor's `manage_options` checkbox. But it opens the Settings menu to the Editor. I checked the `edit_theme_options` for Editor, but it doesn't work. I changed the `theme-options.php`'s `add_theme_page()` capability to even lower to `edit_published_posts` (Author capability), but not worked here. I tried deactivating User Role Editor, but no luck.


How to add a code for lastpostdate after/inside a specific menu link?

So, I have a news website. The designers want me to have a link in the menu that says "Latest News - [time of the last post]". I know I can get the datetime of the latest post with get_lastpostdate(). But how can I put this php code inside the menu? This specific link is not the first one nor the last. It's inside the menu structure. Menus in this website are made trough the usual custom menu tools of wp. Any ideas?


Getting label name of extra user fields

I'm using the plugin "Extra User Fields" to add extra fields to the user's profile. I know how to get the value of the field (get_user_meta/get_author_meta), but I also want the label as a string, but I don't want to get the full code (like `<label>Label</label><input value="value" />` etc., because I want to be able to do with the label and the value what I please. So, what function (or tag) should I use to get the label value of an user field?


Include files for a plugin not including

I have a plugin which I need to include a file in but it doesn't include. Here's the example of the tree:               plugin folder         /themes         /folder2         /somefiles         /includeme.php      Within themes is               /default     /theme2      Then within each theme are the files E.g.               Header.php     Footer.php      The plugin simply switches these themes via the admin. Now in header.php I added               <?php include('includeme.php'); ?>      Which didn't work. A friend told me since it is two levels up the tree I should actually add               <?php include('/../../includeme.php'); ?>.      Both didn't work. I googled something that said to try.               <?php include([$_SERVER]['DOCUMENT_ROOT']'./wp-content/plugins/plugin-name/includeme.php'); ?>.      That also didn't work. This is a basic plugin which renders theme based on admin settings combined with user agent detection. Any suggestions or further code required? The code is located at http://pastebin.com/A3buAA0R


Redirect loop upon installation of my plugin

I have created a plugin that uses a shortcode [MyCreditStatus] to display a form (multi-page form). This plugin uses an API that I also made. When I try to install the plugin, there are times that it causes a redirect loop. It also does not run properly locally because of the sessions (headers already sent, etc.) There are times that it works well too. This is the first plugin I've made using WordPress and I'm not really familiar with WordPress plugin development and I find the resources so limited. I can't find a resource for dealing with forms and passing variable values from page to page. Can you please see the plugin I've made and suggest ways on the correct way that I should be doing it? Here's the download link for the plugin: http://1drv.ms/1qYoTIx Thank you.


Style the text before <!--more--> in single.php

I'd like to style differently the content before the link, but in single.php. To be more specific, all my posts on the homepage only have a summary, and the rest of the text is cut thanks to the use of the more tag. So when I click on "read more" I see the complete post, starting with the summary we previously seen on the homepage. I'd like to differentiate this summary from the rest of the text, adding it some bold for example, to show to the user what he as already read. Unfortunately I think this is not possible. Is it ?


how  to have custom post template including custom write panels for the users to post

I would like to have a separate custom page where the logged in users can post their content. Add post title, add content, add check boxes, image/file uploads, Is there any way to do so?


Carrying values from page to page using custom query

Im having trouble paging a custom query and I hope one of you can spot my error and point it out. I've been looking at it for long time and tried many solutions but none seem to work. The code which generates the "Refine Your Search" form as seen on this page:               http://208.78.226.27/~tots411/business/

Refine Your Search
         <form action="<?php echo home_url( '/' ); ?>business-directory/advanced-search/" method="post" class="business-advanced-search advanced-search-form">

County:
             <select name="business-select-county" id="business-select-county">             <option name="select-one" value="-1">Select One</option>             <?php             $county_terms = get_terms( 'location', array( 'hide_empty' => false, 'parent' => 0 ) );             foreach( $county_terms as $county_term ) {                 echo '<option value="' . $county_term->slug .'"';                         if( isset( $_POST['business-select-county'] ) ) {                             $county_term_slug = $_POST['business-select-county'];                             if( $county_term_slug == $county_term->slug ) {                                 echo ' selected="selected"';                             }                         }                 echo '>'. $county_term->name .'</option>';             }             ?>             </select>

Town:
             <select name="business-select-town" id="business-select-town">                 <?php                 if( isset( $_POST['business-select-town'] ) ) {                     // We need the Term ID of the parent Location                     $parent_term = get_term_by( 'slug', $_POST['business-select-county'], 'location', OBJECT, '' );                     $parent_term_id = $parent_term->term_id;                          $town_terms = get_terms( 'location', array( 'hide_empty' => false, 'parent' => $parent_term_id ) );                     foreach( $town_terms as $town_term ) {                         echo '<option value="' . $town_term->slug .'"';                             if( $_POST['business-select-town'] == $town_term->slug ) {                                 echo ' selected="selected"';                             }                         echo '>'. $town_term->name .'</option>';                     }                 } else {                 ?>                 <option></option>                 <?php } ?>             </select>

Center Type
             <select name="business-select-center-type" id="business-select-center-type">             <option name="select-one" value="-1">Select One</option>             <?php             $center_type_terms = get_terms( 'center_type', array( 'hide_empty' => false ) );             foreach( $center_type_terms as $center_type_term ) {                 echo '<option value="' . $center_type_term->slug .'"';                         if( isset( $_POST['business-select-center-type'] ) ) {                             $center_type_slug = $_POST['business-select-center-type'];                             if( $center_type_slug == $center_type_term->slug ) {                                 echo ' selected="selected"';                             }                         }                 echo '>'. $center_type_term->name .'</option>';             }             ?>             </select>

Program Offered
             <select name="business-select-program" id="business-select-program">             <option name="select-one" value="-1">Select One</option>             <?php             $program_terms = get_terms( 'program', array( 'hide_empty' => false ) );             foreach( $program_terms as $program_term ) {                 echo '<option value="' . $program_term->slug .'"';                         if( isset( $_POST['business-select-program'] ) ) {                             $program_slug = $_POST['business-select-program'];                             if( $program_slug == $program_term->slug ) {                                 echo ' selected="selected"';                             }                         }                 echo '>'. $program_term->name .'</option>';             }             ?>             </select>
                                        <input type="submit" id="business-advanced-search-submit" name="business-advanced-search-submit" class="business-advanced-search-submit" value="Search" />             </form>
      The page handing the form submission and builds the query:               <?php     /* Template Name: Advanced Search - Business Directory */      get_header(); ?>

<?php echo get_the_title( get_the_ID() ); ?>
     <?php $options = get_option('Wcolor_theme_options'); ?>             <?php if ($options['breadcrumb'] == 0): ?>             <?php echo Wcolor_breadcrumb_lists(); ?>     <?php endif; ?>

         <?php Wcolor_header_end(); // after header hook ?>         <?php Wcolor_wrapper(); // before wrapper ?>
         <?php Wcolor_in_wrapper(); // wrapper hook ?>
     <?php     do_action( 'tots_get_business_advanced_search_form' );          $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;     $search_query = array( 'post_type' => 'business', 'posts_per_page' => get_option( 'posts_per_page' ),         'tax_query' => array(), 'paged' => $paged, 'post_status' => 'publish'     );          // Will hold the terms that we are searching for     $existing_terms = array();          if( isset( $_POST['business-select-county'] ) && !empty( $_POST['business-select-county'] ) ) {         if( $_POST['business-select-county'] != -1 ) {             $search_query['tax_query'][] = array(                 'taxonomy'  => 'location',                 'terms'     => $_POST['business-select-county'],                 'field'     => 'slug',             );             $existing_terms[] = 'county';         }     }     if( isset( $_POST['business-select-town'] ) && !empty( $_POST['business-select-town'] ) ) {         if( $_POST['business-select-town'] != -1 ) {             $search_query['tax_query'][] = array(                 'taxonomy'  => 'location',                 'terms'     => $_POST['business-select-town'],                 'field'     => 'slug',             );             $existing_terms[] = 'town';         }     }     if( isset( $_POST['business-select-center-type'] ) && !empty( $_POST['business-select-center-type'] ) ) {         if( $_POST['business-select-center-type'] != -1 ) {             $search_query['tax_query'][] = array(                 'taxonomy'  => 'center_type',                 'terms'     => $_POST['business-select-center-type'],                 'field'     => 'slug'             );             $existing_terms[] = 'center_type';         }     }     if( isset( $_POST['business-select-program'] ) && !empty( $_POST['business-select-program'] ) ) {         if( $_POST['business-select-program'] != -1 ) {             $search_query['tax_query'][] = array(                 'taxonomy'  => 'program',                 'terms'     => $_POST['business-select-program'],                 'field'     => 'slug'             );             $existing_terms[] = 'program';         }     }     if( count( $existing_terms > 1 ) ) {         $search_query['tax_query']['relation'] = "AND";     }          $business_search_query = new WP_Query( $search_query );          if( ( WP_DEBUG == true ) && current_user_can( 'administrator' ) ) {         echo 'County: ',        $_POST['business-select-county'];         echo 'Town: ',          $_POST['business-select-town'];         echo 'Center Type: ',   $_POST['business-select-center-type'];         echo 'Programs: ',      $_POST['business-select-program'];              echo '
';         print_r( $business_search_query );         echo '
';     }          if ( $business_search_query->have_posts() ) : ?>                <?php while( $business_search_query->have_posts() ) : $business_search_query->the_post(); ?>                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__( 'Permanent Link to %s', 'Wcolor' ), the_title_attribute( 'echo=0' )); ?>"><?php the_title(); ?>

                         <?php if ( has_post_thumbnail()) : ?>                             <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                             <?php the_post_thumbnail('thumbnail', array('class' => 'alignleft')); ?>                                                      <?php endif; ?>                         <?php the_excerpt(); ?>

                         <?php the_terms( $post->ID, 'location', 'Location: ', ' / ' ); ?>
                         <?php the_terms( $post->ID, 'center_type', 'Center Type: ', ', ' ); ?>
                         <?php the_terms( $post->ID, 'program', 'Programs Offered: ', ', ' ); ?>

<?php edit_post_link(__('Edit', 'Wcolor')); ?>

     <?php endwhile; wp_pagenavi( array( 'query' => $business_search_query ) );  wp_reset_query(); else: ?>      <?php endif; ?>
     <?php get_sidebar(); ?>     <?php get_footer(); ?>      The main form on `http://208.78.226.27/~tots411/business/` submits to `http://208.78.226.27/~tots411/business-directory/advanced-search/` and the results on this page are accurate. The problem arises when I click on the the link taking me to the second page where the whole query resets and it displays all posts instead of continuing to use my custom query. Any help on this will be highly appreciated. Thank you!


How can we get Catergory / Term Creator

How can we get the category creator id ? I have checked the tables of category/terms viz. wp_terms, wp_term_taxonomy and wp_term_relationships. But there is no information about creator of the category... Is there any function which we can use ?


Shared functionality in plugins and themes

I recently started to develop plugins and themes and I found that I need to use several functions of on both. Sometime I think about to check if function / class exist before declared as said on this post: When to check if a function exists But that is considered as bad practice. What is best practice to prevent conflicts and keep themes & plugin work independently without one themes / plugin installed?


Category.php template for custom posts

I'm trying to use my category.php file to display all posts of a certain custom post type (say "Company") with a given category. However, when I try to use it by navigating to domain.com/category/company/category1, which is the link automatically generated by wp_list_categories(), no posts appear. The code I'm using is:               <?php while ( have_posts() ) : the_post(); ?>     <?php get_template_part( 'type-company', get_post_format() ); ?>     <?php endwhile; ?>      What am I doing wrong?


Execute script only on certain admin pages

To solve this problem i've used this in my js file:               var location = String(window.location);          //only runs in post.php and post-new.php     if(location.search('post.php') != -1 || location.search('post-new.php') != -1 )     {          }      But it's does not seem like i solid solution. Are there any other way?


How to put tags on photos in Windows that WordPress can read and apply on media files?

I'm creating a Stock Photo gallery on WordPress with PhotoPress Image Taxonomies by Peter Adams and I noticed that when I upload photos from iStockphoto, the taxonomies keyword is filled with tags that it originally have on iStockphoto site. I tried doing this on Windows using the tagging feature on windows photo gallery and also on the properties of the image itself but it doesn't appear like that of the image on iStock photo. By the way, this is not a commercial project but an internal for the company to use. So how is iStock photo embedding their keywords on their photo that the plugin by Peter Adams is reading? This will obviously make tagging much easier because when you do tagging on Windows Photo Gallery, you can do it by bulk that WordPress is not able to do.


Image resize using url parmater

I would like to resize image in my wordpress template using url parameter. Best example for this would be Wordpress's very own twenty Twelve theme. Following is link to image with width parameter in the end. If you change width to 50 it'll return image with 50px width. > https://twentytwelvedemo.files.wordpress.com/2012/03/wheat-field.jpg?w=500 I'm confused if its server setting or we can do it using php. Thanks.


SEO module to change tag title for different listing page

I need to have different tag titles for each category of my website. I've tried all in one SEO but it looks like i cannot change it individually. Thanks in advance


collapse twenty twelve submenu in mobile version

in the twenty-twelve theme, the following code will collapse the sub-menu ul/li of the mobile version...the problem is that it also brake the normal version of the menu! how can i use it only when the mobile menu comes in?               jQuery(document).ready(function($){         $('.main-navigation li ul').hide();         $('.main-navigation li').has('ul').click(function() {         $(this).children().toggle();         });     });`


Exclude images uploaded via meta boxes from Wordpress gallery

I am using the following simple get attachment code to display all images attached to a certain post but I want to be able to exclude the images uploaded via a couple of custom meta boxes that are also attached to the post. For example, how could I exclude an image uploaded with a meta key of sample_image_1 from this code?               <?php              $args = array (             'post_type' => 'attachment',             'numberposts' => -1,             'post_status' => null,             'post_parent' => $post->ID,             );             $attachments = get_posts($args);             if ($attachments) {             foreach ( $attachments as $attachment ) {             the_attachment_link( $attachment->ID , 'screenshot' );         }}     ?>


What do the numbers mean at the end of add_action('save_post')...?

I've seen on a few tutorials that there are numbers at the end of the call to save Custom Fields/Meta Boxes on the `save_post` hook. For example, in the WordPress Codex it gives the following example:               <?php add_action( 'save_post', 'my_save_post', 10, 2 ); ?>       What do the **10** and **2** mean at the end? I've tried talking to an "expert", but they've been of no help ;)


Dynamically Generate Functions and Hooks

I'm trying to find if it's possible to dynamically generate functions and hooks. All functions do the same thing, and all hooks are essentially the same. Here's an example of a hook/function combo:               add_action( 'woocommerce_single_product_summary', 'cx_inputKVA_show', 5 );     function cx_inputKVA_show() {         global $product;         // Do not show this on variable products         if ( $product->product_type <> 'variable' ) {             $inputKVA = get_post_meta( $product->id, 'cx_inputKVA', true );             if ( $inputKVA <> '' ) {                 echo '
';                 _e( 'Input KVA: ', 'woocommerce' );                 echo '' . _e( $inputKVA ) . '';                 echo '
';             }         }     }      I want to use an array like:               $fieldset = array(         array(             1 => 'slug',             2 => 'title'         )         array(             1 => 'slug',             2 => 'title'         )     );      And then use a `foreach()` loop to generate 3 hooks and 3 functions for each nested array. Before, I was just writing each one separately, but now I need to generate for 23 items and it's too much code, too messy to change. It would make the hook like:               add_action( 'woocommerce_single_product_summary', 'cx_[plug]_show', 5 );      and the function like               function cx_inputKVA_show() {         global $product;         // Do not show this on variable products         if ( $product->product_type <> 'variable' ) {             $[plug] = get_post_meta( $product->id, 'cx_[plug]', true );             if ( $[plug] <> '' ) {                 echo '
';                 _e( '[title]: ', 'woocommerce' );                 echo '' . _e( $[plug] ) . '';                 echo '
';             }         }     }      Answer------------------ Since Milo is a genius, I got this done much simpler by just looping through the array inside of the function, instead of trying to generate a new function dynamically for each item. The array contains 'slug' and 'title' attributes, and here's the function:               function cx_product_field() {         global $fieldset;         foreach ( $fieldset as $field ){             woocommerce_wp_text_input(                 array(                      'id' => 'cx_'.$field['slug'],                      'class' => 'wc_input_text',                      'label' => __( $field['title'], 'woocommerce' )                 )              );         }     }


Pages 404 in wordpress

First of all, I am very new to wordpress and know almost nothing about it. When I create the page foo using in wp-admin, I get the message that the page is created. When I click on `view page`, it 404s. I've followed the steps on http://codex.wordpress.org/Pages#Creating_Pages, but apparently I'm missing something. I let Wordpress rebuild my `.htaccess`, but still no luck. **System specifications:**   * Ubuntu 13.04   * Apache2   * PHP 5.4.9   * MySQL 14.14 Distrib 5.5.32 **Installed Wordpress Plugins:**   * Debug This   * My own (empty) plugin **.htaccess**               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      **"Debug This" output for query -> rewrite**               Current Rewrite          Matched Rule:      Matched Query:      Query String: debug-this=rewrites          Rewrite Rules          Rule    Rewrite     dating_user/?$  index.php?post_type=dating_user     dating_user/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?post_type=dating_user&feed=$matches[1]     dating_user/(feed|rdf|rss|rss2|atom)/?$ index.php?post_type=dating_user&feed=$matches[1]     dating_user/page/([0-9]{1,})/?$ index.php?post_type=dating_user&paged=$matches[1]     category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?category_name=$matches[1]&feed=$matches[2]     category/(.+?)/(feed|rdf|rss|rss2|atom)/?$  index.php?category_name=$matches[1]&feed=$matches[2]     category/(.+?)/page/?([0-9]{1,})/?$ index.php?category_name=$matches[1]&paged=$matches[2]     category/(.+?)/?$   index.php?category_name=$matches[1]     tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?tag=$matches[1]&feed=$matches[2]     tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ index.php?tag=$matches[1]&feed=$matches[2]     tag/([^/]+)/page/?([0-9]{1,})/?$    index.php?tag=$matches[1]&paged=$matches[2]     tag/([^/]+)/?$  index.php?tag=$matches[1]     type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?post_format=$matches[1]&feed=$matches[2]     type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?post_format=$matches[1]&feed=$matches[2]     type/([^/]+)/page/?([0-9]{1,})/?$   index.php?post_format=$matches[1]&paged=$matches[2]     type/([^/]+)/?$ index.php?post_format=$matches[1]     dating_user/[^/]+/attachment/([^/]+)/?$ index.php?attachment=$matches[1]     dating_user/[^/]+/attachment/([^/]+)/trackback/?$   index.php?attachment=$matches[1]&tb=1     dating_user/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?attachment=$matches[1]&feed=$matches[2]     dating_user/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?attachment=$matches[1]&feed=$matches[2]     dating_user/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$    index.php?attachment=$matches[1]&cpage=$matches[2]     dating_user/([^/]+)/trackback/?$    index.php?dating_user=$matches[1]&tb=1     dating_user/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?dating_user=$matches[1]&feed=$matches[2]     dating_user/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ index.php?dating_user=$matches[1]&feed=$matches[2]     dating_user/([^/]+)/page/?([0-9]{1,})/?$    index.php?dating_user=$matches[1]&paged=$matches[2]     dating_user/([^/]+)/comment-page-([0-9]{1,})/?$ index.php?dating_user=$matches[1]&cpage=$matches[2]     dating_user/([^/]+)(/[0-9]+)?/?$    index.php?dating_user=$matches[1]&page=$matches[2]     dating_user/[^/]+/([^/]+)/?$    index.php?attachment=$matches[1]     dating_user/[^/]+/([^/]+)/trackback/?$  index.php?attachment=$matches[1]&tb=1     dating_user/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$  index.php?attachment=$matches[1]&feed=$matches[2]     dating_user/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$   index.php?attachment=$matches[1]&feed=$matches[2]     dating_user/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$   index.php?attachment=$matches[1]&cpage=$matches[2]     gn-genre/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?taxonomy=gn-genre&term=$matches[1]&feed=$matches[2]     gn-genre/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?taxonomy=gn-genre&term=$matches[1]&feed=$matches[2]     gn-genre/([^/]+)/page/?([0-9]{1,})/?$   index.php?taxonomy=gn-genre&term=$matches[1]&paged=$matches[2]     gn-genre/([^/]+)/?$ index.php?taxonomy=gn-genre&term=$matches[1]     gn-location-3/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$  index.php?taxonomy=gn-location-3&term=$matches[1]&feed=$matches[2]     gn-location-3/([^/]+)/(feed|rdf|rss|rss2|atom)/?$   index.php?taxonomy=gn-location-3&term=$matches[1]&feed=$matches[2]     gn-location-3/([^/]+)/page/?([0-9]{1,})/?$  index.php?taxonomy=gn-location-3&term=$matches[1]&paged=$matches[2]     gn-location-3/([^/]+)/?$    index.php?taxonomy=gn-location-3&term=$matches[1]     gn-location-2/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$  index.php?taxonomy=gn-location-2&term=$matches[1]&feed=$matches[2]     gn-location-2/([^/]+)/(feed|rdf|rss|rss2|atom)/?$   index.php?taxonomy=gn-location-2&term=$matches[1]&feed=$matches[2]     gn-location-2/([^/]+)/page/?([0-9]{1,})/?$  index.php?taxonomy=gn-location-2&term=$matches[1]&paged=$matches[2]     gn-location-2/([^/]+)/?$    index.php?taxonomy=gn-location-2&term=$matches[1]     gn-location-1/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$  index.php?taxonomy=gn-location-1&term=$matches[1]&feed=$matches[2]     gn-location-1/([^/]+)/(feed|rdf|rss|rss2|atom)/?$   index.php?taxonomy=gn-location-1&term=$matches[1]&feed=$matches[2]     gn-location-1/([^/]+)/page/?([0-9]{1,})/?$  index.php?taxonomy=gn-location-1&term=$matches[1]&paged=$matches[2]     gn-location-1/([^/]+)/?$    index.php?taxonomy=gn-location-1&term=$matches[1]     robots\.txt$    index.php?robots=1     .*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$    index.php?feed=old     .*wp-app\.php(/.*)?$    index.php?error=403     .*wp-register.php$  index.php?register=true     feed/(feed|rdf|rss|rss2|atom)/?$    index.php?&feed=$matches[1]     (feed|rdf|rss|rss2|atom)/?$ index.php?&feed=$matches[1]     page/?([0-9]{1,})/?$    index.php?&paged=$matches[1]     comments/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?&feed=$matches[1]&withcomments=1     comments/(feed|rdf|rss|rss2|atom)/?$    index.php?&feed=$matches[1]&withcomments=1     search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?s=$matches[1]&feed=$matches[2]     search/(.+)/(feed|rdf|rss|rss2|atom)/?$ index.php?s=$matches[1]&feed=$matches[2]     search/(.+)/page/?([0-9]{1,})/?$    index.php?s=$matches[1]&paged=$matches[2]     search/(.+)/?$  index.php?s=$matches[1]     author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?author_name=$matches[1]&feed=$matches[2]     author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$  index.php?author_name=$matches[1]&feed=$matches[2]     author/([^/]+)/page/?([0-9]{1,})/?$ index.php?author_name=$matches[1]&paged=$matches[2]     author/([^/]+)/?$   index.php?author_name=$matches[1]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$    index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]     ([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]     ([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]     ([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$    index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]     ([0-9]{4})/([0-9]{1,2})/?$  index.php?year=$matches[1]&monthnum=$matches[2]     ([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?year=$matches[1]&feed=$matches[2]     ([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$  index.php?year=$matches[1]&feed=$matches[2]     ([0-9]{4})/page/?([0-9]{1,})/?$ index.php?year=$matches[1]&paged=$matches[2]     ([0-9]{4})/?$   index.php?year=$matches[1]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$  index.php?attachment=$matches[1]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$    index.php?attachment=$matches[1]&tb=1     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?attachment=$matches[1]&feed=$matches[2]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ index.php?attachment=$matches[1]&feed=$matches[2]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$ index.php?attachment=$matches[1]&cpage=$matches[2]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&paged=$matches[5]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$    index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$   index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$ index.php?attachment=$matches[1]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$   index.php?attachment=$matches[1]&tb=1     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?attachment=$matches[1]&feed=$matches[2]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?attachment=$matches[1]&feed=$matches[2]     [0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$    index.php?attachment=$matches[1]&cpage=$matches[2]     ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$    index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]     ([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$ index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]     ([0-9]{4})/comment-page-([0-9]{1,})/?$  index.php?year=$matches[1]&cpage=$matches[2]     .?.+?/attachment/([^/]+)/?$ index.php?attachment=$matches[1]     .?.+?/attachment/([^/]+)/trackback/?$   index.php?attachment=$matches[1]&tb=1     .?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$   index.php?attachment=$matches[1]&feed=$matches[2]     .?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$    index.php?attachment=$matches[1]&feed=$matches[2]     .?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$    index.php?attachment=$matches[1]&cpage=$matches[2]     (.?.+?)/trackback/?$    index.php?pagename=$matches[1]&tb=1     (.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$    index.php?pagename=$matches[1]&feed=$matches[2]     (.?.+?)/(feed|rdf|rss|rss2|atom)/?$ index.php?pagename=$matches[1]&feed=$matches[2]     (.?.+?)/page/?([0-9]{1,})/?$    index.php?pagename=$matches[1]&paged=$matches[2]     (.?.+?)/comment-page-([0-9]{1,})/?$ index.php?pagename=$matches[1]&cpage=$matches[2]     (.?.+?)(/[0-9]+)?/?$    index.php?pagename=$matches[1]&page=$matches[2]      I also verified that Apache's `mod_rewrite` module is installed and enabled. **apache2.conf (comments removed):**               LockFile ${APACHE_LOCK_DIR}/accept.lock          PidFile ${APACHE_PID_FILE}          Timeout 300          KeepAlive On          MaxKeepAliveRequests 100          KeepAliveTimeout 5          <IfModule mpm_prefork_module>         StartServers          5         MinSpareServers       5         MaxSpareServers      10         MaxClients          150         MaxRequestsPerChild   0     </IfModule>          <IfModule mpm_worker_module>         StartServers          2         MinSpareThreads      25         MaxSpareThreads      75          ThreadLimit          64         ThreadsPerChild      25         MaxClients          150         MaxRequestsPerChild   0     </IfModule>          <IfModule mpm_event_module>         StartServers          2         MinSpareThreads      25         MaxSpareThreads      75          ThreadLimit          64         ThreadsPerChild      25         MaxClients          150         MaxRequestsPerChild   0     </IfModule>          User ${APACHE_RUN_USER}     Group ${APACHE_RUN_GROUP}          AccessFileName .htaccess          <Files ~ "^\.ht">         Order allow,deny         Deny from all         Satisfy all     </Files>          DefaultType None               HostnameLookups Off          ErrorLog ${APACHE_LOG_DIR}/error.log          LogLevel warn          Include mods-enabled/*.load     Include mods-enabled/*.conf          Include ports.conf          LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined     LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined     LogFormat "%h %l %u %t \"%r\" %>s %O" common     LogFormat "%{Referer}i -> %U" referer     LogFormat "%{User-agent}i" agent          Include conf.d/          Include sites-enabled/          Include /etc/phpmyadmin/apache.conf


Multisite WordPress nginx uploaded files throw 404

I have a WordPress subdomain multisite install in the `/blog` subdirectory running on an nginx server. Everything works fine except files which do upload correctly but are not accessible via their url. The part of the config concerning the files is:               location ~ ^/files/(.*)$ {         try_files /blog/wp-content/blogs.dir/$blogid/$uri /blog/wp-includes/ms-files.php?file=$1 ;         access_log off; log_not_found off; expires max;     }          #avoid php readfile()     location ^~ /blogs.dir {         internal;         alias /var/www/example/public_html/blog/wp-content/blogs.dir;         access_log off; log_not_found off;      expires max;     }      and               map $http_host $blogid {         default       -999;              #blog         example.com             1;         a.example.com           2;         b.example.com           3;         c.example.com           4;     }      The WordPress sites have the following settings: Upload Path: `wp-content/blogs.dir/1/files/` Upload Url Path: `http://example.com/blog/files` Fileupload Url: `http://example.com/blog/files` The number in the Upload Path is of course different for each site. When I try to upload a file to any blogpost of any of the sites it does appear in the `/blog/wp-content/blogs.dir/#/files/` folder but if I try to access `/blog/wp-content/files/test.png` it throws 404 Any ideas? Thanks!


Serial Number Delivery System Using WordPress

I'm developing a system where user can buy scratch card number using pre-paid balance. I already created balance system using user meta. Now I need to delivery card number to users upon payment. As payment system is ready, I need an idea which will help me to deliver card number. Card numbers will be stored in database. I'll deliver them. Custom post type can be used probably but couldn't recognize how I deliver them. For instance, User want buy a card of $10. I already stored 5 cards of $10, 3 cards of $20. If user make payment, system will deliver the card number which wasn't previously sold. I need idea. Please suggest me. _Update: I got an idea. I'll create a custom post type called 'Card' with three meta key fields called 'Amount', 'Number' and 'Status'. When a specific function will run, a query will be run for searching the post type for certain amount and where Status will be "Unused". Then an email will be sent to the user with the card number and custom field 'Status' will be updated to "Used". Now I need an idea to search the post. I appreciate your help._


wp-e-commerce plugin - custom payment option

**How to add "Cash on delivery"** in payments options? Also if that option is selected, user should get "invoice" by email. I'm using wp-e-commerce plugin.


Drawing the line between theme & plugin on large scale bespoke projects

With most of my sites, sprinkling in the functionality within the theme seemed the logical way to go. For example, a site with a 'product' post type, or a few options in a meta box or setting page. On a couple of much larger projects though, it would've been crazy to keep it all in the theme, & was a lot easier to abstract the functioniality into reusable plugins. But now I'm at the stage where the requirements are so specific, I'm writing a bespoke plugin to work alongside the theme, and I'm struggling with deciding what (if anything) should remain in the theme or go in the plugin (& furthermore, to break up the plugin into several to handle each component of the site). It'd be great to hear of other similar situations, & generally how you guys approach large scale projects on WordPress.


Load visual editor without custom styling

I have a plugin that uses the `wp_editor()` function to load an instance of the TinyMCE editor. However, the editor is affected by custom styling to make it look similar to the theme through the `add_editor_style()` function. While this may be great in giving the user an idea of how the content may look on the front-end, I do not want this as the content will only ever be displayed on the back-end. Is there any way to load an instance of the WordPress editor without it being affected by custom styling?


Free chat plugin

Is there a Wordpress plugin that allows users to have private chat with an admin but that there is no need for a payment plan (like you have with support sites such as OGG or 123flashchat). I just want a simple chat box that tells users whether I'm online or not and lets them contact me through it.


Stop 'alt' from being added to the_post_thumbnail

I'm using the_post_thumbnail to display a specific thumbnail size. The function outputs an 'alt=' tag with the description of the attachment. Is it possible to clear the value in the ouput? So it'll display `alt=""`?


How to disable thumbnail filter for a specific template part or image size?

I am filtering post_thumbnail_html in my theme to modify the output of my image tags. I have one template part that I would like this filter not to apply to. It uses an image-size that is used no were else in the theme. So I am looking for a way to have this filter not apply on a specific template part or for a specific image size, either way works. Is this possible. I don't think the filter itself matters, but just in case here it is:                if (! function_exists('_sf_responsive_img') ) :      function _sf_responsive_img($html, $post_id, $post_thumbnail_id, $size, $attr) {          //make image links          $attachment_id = $post_thumbnail_id;          $default = wp_get_attachment_image_src($attachment_id);          $size = 'fd-sm';          $small = wp_get_attachment_image_src($attachment_id, $size);          $size = 'fd-med';          $med = wp_get_attachment_image_src($attachment_id, $size);          $size = 'fd-lrg';          $lrg = wp_get_attachment_image_src($attachment_id, $size);          //create image tag with queries          $html = '<img src="'.$default[0].'"';          $html .= 'data-interchange="['.$default[0].', (default)],';          $html .= '['.$small[0].', (only screen and (min-width: 320px))],';          $html .= '['.$med[0].', (only screen and (min-width: 768px))],';          $html .= '['.$lrg[0].', (only screen and (min-width: 1024px))],';          $html .='">';          return $html;      }      add_filter('post_thumbnail_html', '_sf_responsive_img', 5, 5);      endif; // ! _sf_responsive_img exists


How do I add a fixed value to get_post_meta();?

I'm using the following to display a custom field value in my posts: `<?php echo get_post_meta($post->ID, 'wikipedia', true); ?>` How do I add this value to the output, where '$tag' takes the tag of the post: `\- <a href="wikipedia.org/wiki/**$tag**">Wikipedia</a>` What I've tried, unsuccessfully: `<?php echo get_post_meta($post->ID, 'wikipedia', true . '- <a href="wikipedia.org/wiki/$tag">Wikipedia</a>'); ?>`


Is get_option function cached?

In my plugin, I use the following code to retrieve an option from the database:               $options = get_option('my_plugin_options');      If I use this 10 times in various functions of my plugin, does WordPress make 10 queries to the database, or does it only make 1 database call per HTTP request and cache the results?


Saving images from Gravity Forms repeatable File Upload as post attachments

I am trying to upload multiple images as attachments to a post using Gravity Forms and the Gravity Forms + Custom Post Types plugin. I have a repeatable File Upload field using the Gravity Forms gform_column_input_filter. See this question for how it was achieved. I then adapted this code from BandonRandon to use the repeatable File Upload field as below:                add_filter("gform_after_submission", "nifty_add_post_attachements", 10, 3);      function nifty_add_post_attachements($entry) {           //you'll need this later, TRUST ME.      if ( !function_exists('wp_generate_attachment_metadata') ) {         require_once(ABSPATH . 'wp-admin/includes/image.php');      }          //do we even have a file?      if ( isset($_FILES['input_2']) ) {          $file_urls = $entry['2']; //great but what is its url?          $file_array = unserialize($file_urls);               foreach ( $file_array as $file_url ) {                   $upload_dir = wp_upload_dir(); //where do you want to put it?              $file_data = file_get_contents($file_url); //show me what you're made of              $filename = basename($file_url); //so cute but what's its name?              if(wp_mkdir_p($upload_dir['path'])) //can we put it there?              $file = $upload_dir['path'] . '/' . $filename; //yes great              else //or no, okay fine let's try somewhere else              $file = $upload_dir['basedir'] . '/' . $filename; //get the whole location              file_put_contents($file, $file_data); // tada home at last                  $wp_filetype = wp_check_filetype($filename, array('jpeg' => 'image/jpeg','jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png') ); //is it the right type of of file?              $attachment = array( //set up the attachment              'post_mime_type' => $wp_filetype['type'],              'post_title' => sanitize_file_name($filename),              'post_content' => '',              'post_status' => 'inherit'              );                  $attach_id = wp_insert_attachment( $attachment, $file, $entry['post_id'] ); //insert attachment             $attach_data = wp_generate_attachment_metadata( $attach_id, $file ); //asign the meta             wp_update_attachment_metadata( $attach_id, $attach_data ); //update the post         }         //remove the entry          //(to keep the entry comment or delete these line)          // IMPORTANT See:  http://pastebin.com/quvsvGHJ for the function          /*if(!function_exists('sedc_gform_remove_entries')){ die('next time maybe you should read the comments');}          else{ nifty_gform_remove_entries($entry, $form );}*/      }     }      I have tried dumping the $_FILES['input_2'] using the following code at the top of the nifty_add_post_attachements function but no output appears on my screen, the post is still created, and the form ajax loading spinner just hangs.               <pre>         <?php print_r($_FILES['input_2']); die();?>     </pre>      Any help or pointers in the right direction would be appreciated.


How we exclude current post form related posts

When user open any post, then on the right side they can see related `posts` to that post. But currently in related `posts` my current open post also showing, how i can `exclude` that post which is currently open.


add_menu_page() with variable function

How can I use `add_menu_page()` functions some variable function ?               add_menu_page('My page','My page','manage_options','my_page', 'func' );          $func = function() {             echo "Done !";     };      I know I can use like               function func() {                 echo "Done !";     };      But how can I use like               $func = function() {                 echo "Done !";     };      to call it ?


How to localized one js file for different actions?

I have a group of javascript functions in one js file. each function acts on a specific action and get its own ajax response. some are on different pages, some are on the same page. If I don't do the localize, I can't get response. How can I localize this file for multi actions?


How to enlarge thickbox media library iframe?

The iframe in thickbox media library is not big enough to display my custom tab. I tried to add "width=900&height=600" at the end of the link that pointing to the library, but no luck. How can I modify the inframe size?


Custom post type's permalink adds the name of the post type before the post name

So I've create a custom post type which seem to work. however the permalinks of the create posts has the name of the custom post type in-front of the post name. I am getting addresses like: `http://demoforhim2.e-ddl.com/movie_reviews/secondone/` and trying to change that to : `http://demoforhim2.e-ddl.com/secondone/` From reading some articles e.g http://wordpress.org/support/topic/custom-post- type-permalink-rewrite this is possible I've tried using rewrite with empty slug but it did not work. Here is my custom post type               add_action( 'init', 'create_movie_review' );     function create_movie_review() {     register_post_type( 'movie_reviews',         array(             'labels' => array(                 'name' => 'Movie Reviews',                 'singular_name' => 'Movie Review',                 'add_new' => 'Add New',                 'add_new_item' => 'Add New Movie Review',                 'edit' => 'Edit',                 'edit_item' => 'Edit Movie Review',                 'new_item' => 'New Movie Review',                 'view' => 'View',                 'view_item' => 'View Movie Review',                 'search_items' => 'Search Movie Reviews',                 'not_found' => 'No Movie Reviews found',                 'not_found_in_trash' => 'No Movie Reviews found in Trash',                 'parent' => 'Parent Movie Review'             ),             'public' => true,             'menu_position' => 15,             'supports' => array( 'title', 'editor', 'comments', 'thumbnail' ),             'taxonomies' => array( '' ),             'menu_icon' => plugins_url( 'images/16x16.png', __FILE__ ),             'has_archive' => true,             'rewrite' => array('slug' => '', 'with_front' => FALSE) /*doesnt seem to work*/         )     );     }      for some reason the above doesn't work properly.


WordPress PHP version requirements

PHP 5.5 has been released recently. In the same time has been announced that PHP 5.3.x branch won't be supported anymore after 5.3.27 will be released. However WordPress requires PHP version 5.2.4 and higher. I understand that WordPress guaranties that it will work on a hosting with PHP 5.4 or 5.5 installed. But in the same time it means that I can't use PHP 5.3, 5.4 or 5.5 features in my WP development as it could cause an issue on a hosting with PHP 5.2.x installed. If I use PHP 5.3 and higher features in my plugins/themes, then they are won't be 100% compatible with WordPress. Does anybody knows if WordPress is going to change it's requirements?


how to get the top 10 popular blogs

Our wordpress sites have `many many users`, each of them have an blog account, they can write posts,comments and so on. Now I want to find out `the top 10 popular blogs`, according to or order by `comments`, or `blog visite number`, or manybe `some other stands`. Yes, I can find out the most 10 comments of the posts, but can I get the blogs? A litter difficult. Anyone could you please show me some ideas, thanks in advanced.


get_var is neither a string, integer, or array ...?

$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND                                   company = %s", $product, $company));             if(is_int($vote_count)){                 $html = '                 Vote here (' . $vote_count . ' Votes for ' . $product . ' and ' . $company . ')';             }else{                 if(is_string($vote_count)){                     $html = '$vote_count is a string in the database
' . print_r($vote_count);                 }if(is_array($vote_count)){                     $html = '$vote_count is an array in the database
' . print_r($vote_count);                 }else{                     $html = '$vote_count is not a string or an integer
' . print_r($vote_count);                 }             }      And my output: > $vote_count is not a string or an integer > > 1


Menu not styling. New menus functionality giving me a headache

I can't find a good tutorial on the new menu handling functions, and the ones I found don't seem to work for me. What am I doing wrong? In my `functions.php`: (I'm using the Blank Slate theme as a framework; I'll figure out later what's noise, but it's pretty minimal -- hence the name)               function blankslate_register_menus() {         register_nav_menus( array( 'main-menu' => __( 'Main Menu', 'blankslate' )));     }      Next, on `header.php`:               <nav>         <?php wp_nav_menu( array( 'theme_location' => 'main-menu' ) ); ?>     </nav>      And finally, testing my `style.css` for every possible option:               .main-menu, .main-menu *, #main-menu *, #main-menu {         font-size: 40px;     }      Does nothing. The menu items are simply listed like a simple HTML `<ul>` would be. I've followed this tutorial: http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus which is the opnly decent and recent one I found, but I don't see what I've done different. (if I try the class `.menu`, it works, so the problem is in what I'm assuming the classes are?) Also, the tutorial mentions a whole lot of parameters that cane be added to the `register_nav_menu()` function, like custom tags, and using `<div>` by default, yet no mention of how to actually set them. Any help? My theme is almost done and I've been stuck on a freaking menu function all day... I'd've made a menu old school by now :/


How do I add multiple post types to this query?

The code i use calls for all attachments that are uploaded to be in the post. I added the Gallery custom post type but nothing shows. It shows on my "pretty-little-liars" post type though. What am I doing wrong.                  <?php          if ( 'pretty-little-liars','gallery' == get_post_type() ) { //condition to show     gallery on post type - gallery          if ( $attachments = get_children( array(         'post_type' => 'attachment',         'post_mime_type'=>'image',   //return all image attachment only         'numberposts' => -1,   //get all the attachments         'post_parent' => $post->ID     )));          foreach ($attachments as $attachment) {         // you can customize the oputput         echo '

';         echo ''.wp_get_attachment_link( $attachment->ID,'full' , false, false );         echo '
';         echo ''.$attachment->post_excerpt.'

';         echo '

'.$attachment->post_title. '
';         echo ''.$attachment->post_content.'';         echo '

';     }     }          ?>


Submiting custom form give error 404

I have custom search form on category `category.php` list template with following code:               <?php $searchresults = site_url('/?p=1365'); ?>          <form class="search-slide" id="search-slide" name="search-slide" action="<?php echo $searchresults; ?>" method="post">         <input type="text" name="s_name" id="s_name" size="30" value="" class="find s-name" placeholder="Name Lastname" tabindex="1" />         <input type="text" name="s_offer" id="" size="30" value="" class="find s-tag"  placeholder="in research offer" tabindex="2" />         <input type="text" name="s_area" id="" size="30" value="" class="find s-obsz"  placeholder="in Application area" tabindex="3" />         <input name="s_tags" id="tag-list" value="" tabindex="4" />              <input class="slideradio" type="checkbox" id="w01" name="w[]" value="w01" />             Faculty of Architecture         <input class="slideradio" type="checkbox" id="w02" name="w[]" value="w02" />             Faculty of Civil Engineering         <input class="slideradio" type="checkbox" id="w03" name="w[]" value="w03" />             Faculty of Chemistry              <input class="slideradio" type="radio" id="adefault" name="s_sort" value="" checked="checked"  tabindex="6"/>         Default         <input class="slideradio" type="radio" id="aasc" name="s_sort" value="" tabindex="7" />         Sort A-Z         <input class="slideradio" type="radio" id="adsc" name="s_sort" value="" tabindex="8" />         Sort Z-A              <button id="slide_search_btn" type="submit">Search</button>     </form>      And I'd like to send variables into another wordpress website `search- result.php` (template page is added and published in dashboard). But when I click `Search` button I get error 404 (I have red about naming `name fields` but I think mine are Ok). But when I enter page directly in browser I got page normally. Can anybody direct me how to resolv this problem?


why php tag is not working if i store and show it in wp_head?

hi i used wp_head a couple of times.I echoed some values it works like below               function test()     {     echo "hello am visible";     }     add_action('wp_head','test');      but if i store a php code in db and retrieve it to a variable and echoed it is not working, here is the sample               <?php echo "i will go to db and come again"; ?>      i stored the above value in LONGTEXT format in db as `trial` then i selected the table and assigned it to a variable like below               $output = $result->trial;      Here come the problem part               function test()         {         //after retrieve          echo $output;         }     add_action('wp_head','test');      this way it is not working.i can't able to see i will go to db and come again. What is the problem? Thanks


Create more than one section in Theme Customizer

i tried to create more than one section in Theme Customizer, but had no success with that.               /* Theme customize - Create menu bar link */     function example_customizer_menu() { add_theme_page( 'Customize', 'Customize', 'edit_theme_options', 'customize.php' ); }     add_action( 'admin_menu', 'example_customizer_menu' );      How i got it for all of new sections (tabs) in Theme Customizer i must to write code below. Is it right?               /* Create one new tab */     add_action('customize_register', 'themedemo_customize');     function themedemo_customize($wp_customize) {          $wp_customize->add_section( 'themedemo_demo_settings', array(         'title'          => 'Demonstration Stuff',         'priority'       => 35,     ) );          $wp_customize->add_setting( 'some_setting', array(         'default'        => 'default_value',     ) );          $wp_customize->add_control( 'some_setting', array(         'label'   => 'Text Setting',         'section' => 'themedemo_demo_settings',         'type'    => 'text',     ) );          $wp_customize->add_section( 'themedemo_demo_settings', array(         'title'          => 'Demonstration Stuff',         'priority'       => 40,     ) );          $wp_customize->add_setting( 'some_other_setting', array(         'default'        => '#000000',     ) );          $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'some_other_setting', array(         'label'   => 'Color Setting',         'section' => 'themedemo_demo_settings',         'settings'   => 'some_other_setting',     ) ) );          }      For what did we use "customize_register" and why there is always different words? How i got it "themedemo_customize" it is like parameter here..               add_action('customize_register', 'themedemo_customize');     function themedemo_customize($wp_customize) {      I read official documentation but did not get it.


WPAlchemy: How to output values?

I am using http://www.farinspace.com/wpalchemy-metabox/ and have created my meta boxes and the data is being saved successfully (See below) but I don't know how to output these 'ingredients' on the front end?               Array     (         [docs] => Array         (             [0] => Array             (                [ingredient] => Cheese             )             [1] => Array             (                [ingredient] => Salt             )         )     )      **This is my single.php**               <?php     global $simple_mb;     $meta = $simple_mb->the_meta();     ?>      **This is my meta.php**
              <?php while($mb->have_fields_and_multi('docs')): ?>         <?php $mb->the_group_open(); ?>                  <?php $mb->the_field('ingredient'); ?>
                 Ingredient                 <input class="text" type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>                 Remove
              <?php $mb->the_group_close(); ?>         <?php endwhile; ?>
<?php echo __('Add Ingredient'); ?>

      **This is my functions.php**               // Meta WP Alchemy     include_once 'metaboxes/setup.php';          $custom_metabox = $simple_mb = new WPAlchemy_MetaBox(array     (         'id' => '_custom_meta_ingredient',         'title' => 'Recipe Ingredients',         'types' => array('recipe'),         'mode' => WPALCHEMY_MODE_EXTRACT,         'prefix' => '_ingredient_',         'autosave' => TRUE,         'template' => get_stylesheet_directory() . '/metaboxes/ingredients-meta.php',     ));


How do I enforce users to fill a determined custom field using WyPiekacz?

I have a Wordpress + Buddypress site. I've created two custom fields which **must** be filled in each post. Also, I have a form in a custom metabox to show them. I'm using WyPiekacz plugin to check for minimun words, tags, and categories. So it would be nice if I can tweak it a litle to check if these custom fields were filled or not, and set the post status to draft if the custom fields were empty. Thanks :)


get user list in admin area

how can I fetch a list of registered users and show it in the admin panel. I know theres the list inside the admin panel already but I've added a few tables and I need to show them in a new tab menu inside the admin panel.


Letting clients use visual builders plugins/themes on WordPress Multisite installation

I use WordPress Multisite to create and manage my users websites. I was wondering - Is it possible (and legal by copyright laws) to buy one of those visual builders plugins/themes and **also let my clients use them for their site?** I know it's possible to use them for building my clients site, but i'm not sure about giving **them** access to the tool.


How to remove certain words from url slug

Trying to create a SEO plugin, that will remove stop words from slugs. This is how to `explode` the `$slug` into a list, and explode the variable containing the stop words :               add_filter ('sanitize title', 'remove_false_words');     function remove_false_words($slug) {         if (!is_Admin()) return $slug;              $slug = explode ('-', $slug);              foreach ($slug as $key => $word) {             //The $slug has been exploded and retrieves its value                  $keys_false = 'a,above,the,also';             $keys = explode (',', $keys_false);                  foreach ($keys as $1 => $wordfalse) {                 if ($word == $wordfalse) {                     unset ($slug[$k]);                 }             }         }         return implode ('-', $slug);     }      Is it correct to `unset` the value here? Or should I use a different way of achieving the same result?


Change comment author after new comment posted

I'm trying to update the user_id of a comment once it has been posted. It looks to see if the comment_author_email exists as a user in the users table, and if it does, attach that user to the comment.               function set_comment_author($comment_ID){         global $wpdb;              $comment = get_comment($comment_ID, ARRAY_A);         if($comment["user_id"] == 0){             $user = get_user_by('email', $comment["comment_author_email"]);             if($user){                 $user_id = $user->ID;                 $comment["user_id"] = $user_id;                 wp_update_comment($comment); //This method doesn't work                      /*                  * This method doesn't work either                    $wpdb->update(                            $wpdb->prefix.'comments',                         array(                             'user_id' => $user_id                         ),                         array(                             'comment_ID' => $comment_id                         )                     );                 $wpdb->print_error();*/             }         }     }     add_action("comment_post", "set_comment_author", 10, 1);      I have done some debugging, and the action is being fired, the comment ID is coming through, and the user_id is being found. So the problem is updating the comment. Both wordpress function and database method don't work. Any ideas?


ajax_wp is returning 0 for attempt of use in frontend

ajax_wp_nopriv_myaction is returning 0. I am trying to insert into a database by passing ajax data to a function. I know its using the javascript file, because it outputs an alert box of what the response is and its 0. I'm guessing it is something that has to do with how I registered the test callback function. A short code creates the form:
                 <form method='post' id='bday-form'>

                             Name:	                              <input id='name' type='text' name='name'/>

                             Birthday:	                             <input id='email_birthday' type='text' name='birthday' />

                             Email:	                             <input id='email_email' type='text' name='email'/>

                             	                             <input style='float:right;' type='button' name='submit' id='submit' value='Submit'><input style='float:right;' type='reset' value='Clear'>

                 </form>
      The same function that creates the form has this at the top:                       //enqeue scripts and callbacks              //add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );             $this->start_scripts();             add_action( 'wp_ajax_my_test', array($this,'test'));             add_action( 'wp_ajax_nopriv_test', array($this,'test'));      the start scripts function and callback function                   function start_scripts() {                wp_enqueue_script( 'script-name', plugins_url() . '/verify-me/js/example.js', array('jquery'), '1.0.0', true );           wp_localize_script( 'script-name', 'MyAjax', array(             // URL to wp-admin/admin-ajax.php to process the request             'ajaxurl' => admin_url('admin-ajax.php'),                  // generate a nonce with a unique ID "myajax-post-comment-nonce"             // so that you can check it later when an AJAX request is sent             'security' => wp_create_nonce( 'my-special-string' )           ));         }              function test() {           check_ajax_referer( 'my-special-string', 'security' );             global $wpdb;                  var_dump( isset( $wpdb ) );             //get the post vars from the form             $data = array("email_name" => "test", "email_birthday"=>"test", "email_email"=>"test");              $wpdb->insert('wp_verify_emails', $data);           die(); // this is required to return a proper result         }      I just have test data going into the database.   Finally the js page:               jQuery(document).ready(function($) {          var data = {         action: 'test',         security : MyAjax.security,         whatever: 1234,         dataType: 'json'     };          jQuery( "#submit" ).click(function( event ) {         event.preventDefault();              //grab the variables to pass         var name = jQuery("#name").val();         var bday = jQuery("#email_birthday").val();         var email = jQuery("#email_email").val();              alert(name + bday + email);         // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php         jQuery.post(MyAjax.ajaxurl, data, function(response) {             alert('Got this from the server: ' + response);         });     });     });


Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites

I've built two WordPress sites. One is public site--people go to it, view my content, etc. The other site is a private course catalog. In the course catalog I have 3 custom post types. The content of the course catalog gets shared to different places via templates that output XML, PDFs, and so on, and then the content also needs to go to my main site. The course catalog posts change from time to time, so the main site needs to update to reflect those changes. I can't figure out HOW, though. I'm hoping the community here can help me figure it out. Using WordPress Export to get the custom post types out form the course catalog and import into the main site works but for two problems: existing posts will not be updated to reflect changes and categories from the course catalog CREATE categories in the main site instead of using the already existing, identically named categories. I've looked into FeedWordPress, but it doesn't do custom post types and custom fields, even if I build an RSS template in the course catalog to show those custom fields. WP All Import says it will do everything but the categories, but I need the categories to map correctly between sites. The content is organized and filtered by category in the course catalog front end. Help? Please?


Can I use wp_add_inline_style() inside a function that gets called from a template file (not a hook)?

I'm building a theme that has a 'layout builder', and one of the layout options is a slideshow. There are customiseable style settings for each instance of a slideshow on any page, which means I need to add custom css for each slideshow. It sounds like `wp_add_inline_style()` should be my answer here, but it's just not working, and I'm assuming it's because I'm calling it too late - the slideshow gets built in a function that is run in the template file, not in a hook. I'll post code anyway, in case it does turn out to be a different problem.               function slideshow_builder( $args ) {         // Some other stuff here              // If we're art directing, get the CSS ready and add it to the page         if( $art ) {             $id = $args['id'];             $m_height = $args['mobile_slide_height'] . 'px';             $t_height = $args['tablet_slide_height'] . 'px';             $l_height = $args['laptop_slide_height'] . 'px';             $art_css = <<<END     #$id .slide-background-holder {         height: $m_height;     }     @media screen and (min-width: 768px) {         #$id .slide-background-holder {             height: $t_height;         }     }     @media screen and (min-width: 1024px) {         #$id .slide-background-holder {             height: $l_height;         }     }     END;              wp_add_inline_style( 'my-stylesheet-already-enqueued', $art_css );     }      Am I doing something wrong? Or is it just because I'm running it too late?