title: gform_after_submission not working as expected

text:
I am trying to augment a value to the `wp_user_meta` table, utilizing Gravity Forms. And I'm not having any luck. I had a version of this working on `gform_pre_submission` (though without the class-sniffing) but I want to do this after submission since there will be PayPal involved and don't want to post until the payment is verified. I was trying to use cssClass as a filter so the other developers are free to create as many gravity forms as they want, provided they use the classes `product_name` and `product_price` Unfortunately, my database is just filling up with fails right now.               // hook onto gravity forms and update payment history field     add_action('gform_after_submission', 'payment_history_handler', 10, 2);     function payment_history_handler($entry, $form){          $current_user = wp_get_current_user();     $payment_history = get_user_meta($current_user->ID, 'payment_history', true);          foreach($form['fields'] as &$field){         if(strpos($field['cssClass'], 'payment_name') === true){             $payment_name = $entry[$field['id']];;         } else {             $payment_name = 'fail';         }         if(strpos($field['cssClass'], 'payment_price') === true){             $payment_price = $entry[$field['id']];         } else {             $payment_price = 1;         }     }          if(!empty($payment_name) && !empty($payment_price)){         $payment_history[] = array('date' => date('U'), 'name' => $payment_name, 'price' => $payment_price);         update_user_meta($current_user->ID, 'payment_history', $payment_history);     }          }      The classes are in place, as seen by this sample of my output:

           What Thing are you choosing?*
             <select name='input_1' id='input_4_1'  class='medium gfield_select' tabindex='1' >               <option value='The first one' >The first one</option>               <option value='The second one' >The second one</option>               <option value='The third one' >The third one</option>             </select>

           Price*
             <input name='input_2' id='input_4_2' type='text'  value='' class='medium' tabindex='2'   />

      Any help is greatly appreciated.


title: Calling information from my theme options page

text:
I'm setting up a theme options page, I used it on a previous theme and thought i could easily just copy it over to the new one.               <?php $options = get_option( 'sample_theme_options' ); ?>     <?php echo $options['introtext'] ?>      this is my functions file               <?php           add_action( 'admin_init', 'theme_options_init' );     add_action( 'admin_menu', 'theme_options_add_page' );           function theme_options_init(){      register_setting( 'sample_options', 'sample_theme_options');     }           function theme_options_add_page() {      add_theme_page( __( 'TriState', 'TriState Options' ), __( 'TriState', 'TriState Options' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );     }      function theme_options_do_page() { global $select_options; if ( ! isset( $_REQUEST['settings-updated'] ) ) $_REQUEST['settings-updated'] = false; ?>
     <?php screen_icon(); echo "
". __( 'TriState Theme Options', 'TriState' ) . "
"; ?>     <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>

<?php _e( 'Options saved', 'TriState' ); ?>

     <?php endif; ?>      <form method="post" action="options.php">     <?php settings_fields( 'sample_options' ); ?>            <?php $options = get_option( 'sample_theme_options' ); ?>

     <?php @readfile("http://www.kevinmonahan.com/news.htm"); ?>

     <?php _e( 'Picture', 'TriState' ); ?>	          <input id="sample_theme_options[picture]" class="large-text" cols="50" rows="1" name="sample_theme_options[picture]" value="<?php esc_attr_e( $options['picture'] ); ?>" />     <?php _e( 'Add the full url to the image you would like at the top', 'TriState' ); ?>

     <?php _e( 'Twitter Handle', 'TriState' ); ?>	          <input id="sample_theme_options[twiturl]" class="large-text" cols="50" rows="1" name="sample_theme_options[twiturl]" value="<?php esc_attr_e( $options['twiturl'] ); ?>" />     <?php _e( 'http://twitter.com/yourprofileurl', 'TriState' ); ?>

<?php _e( 'Intro Heading', 'TriState' ); ?>	          <textarea id="sample_theme_options[introtext]"     class="large-text" cols="50" rows="1" name="sample_theme_options[introtext]"><?php echo esc_textarea( $options['introtext'] ); ?></textarea>     <?php _e( 'This is the large text area at the top of the page. A quick description of yourself is best!', 'TriState' ); ?>

<?php _e( 'Intro Subheading', 'TriState' ); ?>	          <textarea id="sample_theme_options[introsub]"     class="large-text" cols="50" rows="1" name="sample_theme_options[introsub]"><?php echo esc_textarea( $options['introsub'] ); ?></textarea>     <?php _e( 'This is smaller text under the heading. Same idea make it short and sweet!', 'TriState' ); ?>

<?php _e( 'Quick Text - Left', 'TriState' ); ?>	          <textarea id="sample_theme_options[leftquick]"     class="large-text" cols="50" rows="1" name="sample_theme_options[leftquick]"><?php echo esc_textarea( $options['leftquick'] ); ?></textarea>     <?php _e( 'This is a quick heading for the left side. It can be any length.', 'TriState' ); ?>

     <input type="submit" value="<?php _e( 'Save Options', 'TriState' ); ?>" />
     </form>
     <?php } ?>


title: Menu item added with "wp_nav_menu_items" gives "damaged" url

text:
I am adding menu items with the code below, the menu items show up when clicked but they give **damaged** url's e.g for the top link when clicked               http://timothylhanson.com/bp/%3C?php%20return%20bp_loggedin_user_domain()%20?%3Eactivity/just-me/      clearly this               <?php return bp_loggedin_user_domain() ?>      is not being returned properly Any help with this is greatly appreciated Thanks               function add_profile_link_to_nav($items) {         if ( is_user_logged_in() )          return $items .       '
<a href="<?php return bp_loggedin_user_domain() ?>activity/just-me/">My Wall

<a href="<?php return bp_loggedin_user_domain() ?>activity/friends/">My Friends Activities

 <a href="<?php return bp_loggedin_user_domain() ?>profile/edit/group/1">Edit My Profile

';     }     add_filter('wp_nav_menu_items','add_profile_link_to_nav', 10, 2);


title: How to Change Wordpress Image URLs

text: I am facing a problem related to image URLs on one of the website that is bestappspoint.com Most of the images in this site are with capital letters in URL (I didn't know the consequences before) but now I want to redirect all the capital letter in URLs through `.htaccess` file or by adding a rule in SQL databases through phpMyAdmin. Please guide me the rule how to do it.   For example: One URL with capital letters is:               http://www.bestappspoint.com/wp-content/uploads/2013/05/Talking-Speedometer.jpg      I want such all URLs to be redirected like:               http://www.bestappspoint.com/wp-content/uploads/2013/05/talking-speedometer.jpg      In the lower image, URL has no capital letters. Can you guide me what `.htaccess` rule or phpMyAdmin should be added to solve this major problem so that there are no more 404 pages on my website.


title: Rewrite Endpoints and CPTs - How to use in a plugin

text: I'm working on rewrite rules for a plugin that uses a URL endpoint, `/modifier`, to create a `query_var` `&modifier=1` to signify it should do something else. The rewrite deals with URLs where `/modifier` is appended to the end of a URL for a post, page, or custom post type. It seems like adding a rewrite endpoint would be ideal, but according to the Wordpress rewrite endpoints API the incoming URL would need to end with a value, like `/modifier/1` in order to rewrite automatically to `&modifier=1` via the endpoint API. If there's no value after the endpoint, it resolves to `&modifier=` and has no value when checking if it `isset`. So I'm still doing it the long way, via `generate_rewrite_rules`. The rewrite for posts and pages works fine - I could include it but maybe it's not relevant. The rewrite for custom post types, added at the top, also works when a post type is explicitly hardcoded.               add_filter('generate_rewrite_rules', 'my_rewrite');     function my_rewrite($wp_rewrite) {         // rewrite rules for custom post type "specific-type"         $cpt_rules = array(             'specific-type-slug/([^/]+)/modifier' => 'index.php?specific-type='. $wp_rewrite->preg_index(1) .'&modifier=1'         );         $wp_rewrite->rules = $cpt_rules + $wp_rewrite->rules;     }      The problem is making a loop for all custom post types. `get_post_types()` is only available after `init`. This rewrite is filtering `generate_rewrite_rules`, several steps earlier. So here's the loop I've tried. It obviously doesn't work, the post types aren't set up yet.               add_filter('generate_rewrite_rules', 'my_rewrite');     function my_rewrite($wp_rewrite) {       global $wp_post_types;       $types = get_post_types( array( '_builtin' => false ) );       // get the registered data about each post type with get_post_type_object       foreach( $types as $type ) {         $cpt_rules = '';         $typeobj = get_post_type_object( $type );              if( isset( $typeobj->rewrite->slug ) ) {             $slug = $typeobj->rewrite->slug;             $cpt_rules = array(                 $slug.'/([^/]+)/modifier' => 'index.php?'.$type.'='. $wp_rewrite->preg_index(1) .'&modifier=1'             );             $wp_rewrite->rules = $cpt_rules + $wp_rewrite->rules;         }       }     }      Something tells me using a plugin class might be the way to solve this, but I don't understand how.


title: How to Modify WordPress Default Image Gallery Shortcode

text: I would like to be able to show 5 columns and only 10 images per page for the default WordPress image gallery. Visually I would imagine it to look something like the following: > columns="5" pagination="10" How do I go about achieving this?


title: Rewrite custom taxonomy URL

text: I am trying to rewrite a custom taxonomy URL, here is my taxonomy:               register_taxonomy('cpt_category', array('cpt'), array(         'hierarchical' => true,          'labels' => $cpt_labels,         'rewrite' => array('slug' => 'custom-slug/child-slug/', 'with_front' => true)     ));      I want to add custom slugs to URL:               http://example.com/custom-slug/child-slug/cpt_category      I have added my rewrite rule but it is not working, also flushed rewrite rule, still I am getting error 404.


title: Can I use custom post types to build a booking system?

text: I need to build a custom booking system that handles the following. I plan on using custom post types to handle the bookings/packages but need advice as to whether this is a good idea or if I should rather be adding a custom table to the WP database? _**Brief project details_** The booking system will allow admin to do the following:   * add a user, select user level, add personal details   * assign/edit/delete a package to a user (a package would be a contract that allows the user 7 service requests over 3 years, but there are different package types)    * add/edit/delete individual packages (that are assigned to users)   * add/edit/delete bookings The user will be allowed to do the following   * login and view there personal and package details   * make a booking/service request for a certain date So the system would need to monitor the bookings (the details of the user service request eg. date), how many booking the user had made over the package/contract period. I plan on creating a "package" custom post type, add a "booking" custom post type. So when a package is assigned to a user a new "package" custom post type is created with the user ID added as a meta field. When a new booking is made a new "booking" custom post type is created and assigned the user ID. At the same time the booking is added, that users package custom post type meta field for how many bookings they have made is updated. I need to find out if this will be manageable and advisable to do in WordPress?


title: If meta_value = 'yes', then add class?

text: `meta_key=_jsFeaturedPost` `meta_value=yes` I have posts where some have meta keys/values and some don't. I would like to target the ones with the meta keys that have a value of 'yes' and add a CSS class to those posts so I can style them differently. Ideally, something like: if meta_value for meta_key (jsFeaturedPost) is yes, then add class. How would I do this?


title: search page not found? (search.php or searchpage.php)

text: Am i wrong in thinking i can access the search page by using /search/ ? I've created the files search.php & searchpage.php but /search/ still returns 404? I want to customise the page a bit... best, Dan.


title: How to concatenate inside the _e() function the right way?

text: I'm trying to create a function for the title inside my functions.php, I'm having a problem with the search title part where I have to concatenate here's the part with issues:               elseif (is_search()) {     _e('Search for ', 'textdomain') . '"' . esc_html(the_search_quey()) . '$quot; - '; }      this one gives a title like this: Search for searchtermsitename no quotes and the search term is attached to the site name. I tried this one:               elseif (is_search()) {     _e('Search for ' . '"' . esc_html(the_search_quey()) . '$quot; - ', 'textdomain'); }      it doesn't work either, this one outputs: searchtermSearch for "" sitename it's better than the first one but he search query is before, and can't figure out why. so any help, and thanks in advance.


title: switched from query_posts to WP_query, not working now?

text:
So I had asked (in retrospect a pretty non-question) at A little help/cleanup from a real coder? and one of the comments was to not use query_posts and instead use WP_Query. So I did a little digging and tried to implement that, now the code isn't working fully. The MultiPostThumbnails isn't pulling the img I'm only getting the the_post_thubnail not additional img. What am I doing wrong here?               function efs_get_slider(){              $slider= '

';              $my_posts = new WP_Query();         $efs_query= "post_type=slider-image";         $my_posts->query($efs_query);                   if($my_posts->have_posts()) : while ($my_posts->have_posts()) : $my_posts->the_post();                   $flexID = $my_posts->ID;             $img1= wp_get_attachment_image( get_post_thumbnail_id($flexID),'full',0 );             $imagemain =  preg_replace( '/(width|height)=\"\d*\"\s/', "", $img1 );                  if (class_exists('MultiPostThumbnails')) {                 $image_name = 'feature-image-2';                 if (MultiPostThumbnails::has_post_thumbnail('slider-image', $image_name)) {                     $image_id = MultiPostThumbnails::get_post_thumbnail_id(                         'slider-image',                         $image_name,                         $flexID                     );                     $attr = array('class' => "secondaryslider");                     $image = wp_get_attachment_image( $image_id, 'full', false, $attr );                     $imagesecondary = preg_replace(                         '/(width|height)=\"\d*\"\s/',                         "",                         $image                     );                 }             };                  $cttitle = get_the_title();             $ctexcerpt = get_the_excerpt();                  $slider.='

'.$imagesecondary.'
';             $slider.='

'.                 $cttitle.'

'.$ctexcerpt.'

';             $slider.='
'.$imagemain.'

';                   endwhile; endif; wp_reset_postdata();                   $slider.= '

';              return $slider;     }


title: Access to Instance Variables from WP_Query

text: If I make a query to the wordpress database to pull the five most recent posts of some kind, and I would like to do a different treatment to each of them, is there a way to access the individual instance objects? For instance, if I want to do something to the second post object, is there a way to access the object by something along these lines?               $query = new WP_Query( $args );          $query[1] => access to the second post object from the query


title: How can I integrate yepnope.js with Wordpress (and plugins)?

text: To improve my website's loading speed a bit (and to impress the judges--sad reality of the kind of website I'm building, there are judges), I want to implement yepnope.js to load the Javascript dynamically. However, I'm running into a roadblock with the Wordpress jQuery plugins, because Wordpress still embeds them as a script tag. Is there a way to modify Wordpress's script-loading mechanism so that I can just get an array of plugins to feed into Yepnope, or some other solution?


title: Releasing new plugin version, how to rename old options keys?

text: I have everything ready for publishing a new version of my plugin but one last issue stands... The old version had no naming convention for its key option names. The options grew and I renamed all of them, using prefixes for the sake of good coding practice and my own sanity. I thought of putting a warning in the Description and the Changelog, but I think it would be gentler if I could make an internal import method. So, that's the question:   * how to run a function on plugin update?   * and how to check if $myOptions['old_key'] exists, pass it value to $myOptions['new_key'] and finally delete the old_key thanks,


title: triple drop down for populating custom taxonomies

text:
im developing a logic for populating 3 custom taxonomies into 3 drop downs, i have a custom post type dealers and under that i have 3 taxonomies 1. State 2. City 3. Manufacturer when i select the state i have to populate the cities that are related to the state, and when i select the city and i have to populate the manufacturers list in the 3rd drop down that is related to the city that i have selected... This is the example link that i am working on http://carandhalf.com/dealers here is the code for displaying the custom tax in drop down

<?php _e('Locate Dealer'); ?>
         <form action="<?php bloginfo('url'); ?>" method="get">
                 <?php $state_args = array('taxonomy' => 'state', 'hide_empty' => 0, 'depth' => 2); ?>                 <?php wp_dropdown_categories($state_args); ?>

                 <?php $city_args = array('taxonomy' => 'city', 'hide_empty' => 0); ?>                 <?php wp_dropdown_categories($city_args); ?>

                 <?php $man_args = array('taxonomy' => 'manufacturer', 'hide_empty' => 0); ?>                  <?php wp_dropdown_categories($man_args); ?>

                 <input type="submit" name="submit" value="view" />
         </form>
      can anyone help me for filtering the data...... im not a pro in WP, plz bare with me. thanks in advance


title: Create an instance of add_image_size

text: I'm looking for a method to create an instance of `add_image_size();` To elaborate: I am using the file uploader in a plugin to insert a file reference by ID. That ID is then used to create touch icons for the site `<meta>`. But I want to downsize the image to various sizes (57x57px, 72x72px, and 114x114px) on the fly. I don't however want to create a new image size for every attachment image, just this one instance. right now `wp_get_attachment_image_src($id, array(57, 57))` and `wp_get_attachment_image_src($id, array(72, 72))` return the same url. Could I `add_image_size()` in my function, return the images, and then unset the function? Anyone have any thoughts?


title: 2 item in a same menu pointing to 1 page

text:
I have a menu containing 2 item that pointing to 1 page, my question is how do i highlight the top level item according to where i click it.

Home

Funding Guidelines

Learning Institutions

Who Is Eligible

What We Fund

FAQs

Projects

Donations

Make Donation

Request for Tax Exempt Receipts

FAQs

           Referring to above i have two FAQ link, one under Funding Guideline and another one under Donation which both link to the same page. My problem is how to highlight the top-level menu when i click to the link under respective sub- menu, without highlighting the other one. What i have now is that when i click to the menu, it's highlighted both top level menu.


title: Plugin Functionality Only for Editor and Administrator

text: I've never actually written a Wordpress plugin before, so this is my first crack at it. Basically, the plugin is for multi-author blogs where post authors must submit their post for review. The Editor/Administrator must come in and approve and publish/schedule the post. All of this is good, and built into Wordpress. This plugin adds the ability for the Editor/Administrator to leave a comment on the post content, not suggestions for improving the post. This is particularly useful when the Editor schedules the post to publish at a future date/time. The Editor can leave their comment, then when the post publishes, the editor's comment automatically publishes with it.   * I have created a custom meta box with a textarea following this method - Add A Meta Box In WordPress   * I have set the form to save to the database and publish when the post is published using - How can I allow editors to leave comments on posts that have not yet been published? The final thing I cannot figure out is how to make this plugin active only for editor and administrator roles. I do not want the post author to be able to leave comments before the post is published. Essentially, I don't want to require the post editor, who has already read the post, to come back later to leave his/her comments. ## Edit Pastebin of complete code - http://pastebin.com/yG9uqJ7q


title: (resolved) How to show author page link

text: I have the following code:               /*Get number of entries*/         function get_entries_num( $id ) {             $count=  count_user_posts( $id );             if ($count == 1)              {                 return sprintf(__('%s total post','upme'), $post, $count);             } else              {                 return sprintf(__('%s total posts','upme'), $count);             }         }      I want to link "%s total posts" this location `get_author_posts_url($author_id)`. So, I want to display WordPress user all post(author page) when someone click on "%s total posts".


title: What causes an Unexpected HTTP Error within install plugins?

text: Within "install plugins" I'm receiving an error stating "An Unexpected HTTP Error occurred during the API request." When I do a plugin search it throws me back to my site's 404 page. Any idea what would prevent my site from syncing properly with WordPress's servers? ![enter image description here](http://i.stack.imgur.com/TmG5w.png) I added Hameedullah's code to functions.php and recevied this returned `object(WP_Error)#21 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(75) "Could not resolve host: api.wordpress.org; No data record of requested type" } } ["error_data"]=> array(0) { } }` Is this a curl transport issue?


title: Using Custom Taxonomies to organise products - struggling to call a correct list

text: So: I am making a WP site for a company that makes aftermarket performance parts for cars. I have used the post mechanic in WP to add in these parts. Each part has its own page, and I have registered two custom taxonomies: one describes the kind of part that it is, the other describes the kind of vehicle that the part fits. Each part is compatible with several vehicles so each post has a few different terms in the 'compatiblecars' taxonomy but it will only have one term in the 'partstype' taxonomy. To build the navigation for the site, I have a list of the compatible cars and for the menu (which I am using YUI module for, that's not the problem!) I need to call a list of the 'partstype' terms that the posts in each different 'compatiblecars' term have. So, for example, there are twenty parts that are compatible with a Beetle for example, when you click on Beetle I need a list of the five or six different parts types (like, Brake Upgrades for example) that are compatible with the Beetle, and when you click on the term, you go to a page that has all the Brakes Upgrades for Beetles on it. My understanding is that the best way to do this is to do a query_posts that calls all the posts with the 'Beetle' term in the 'compatiblecars' taxonomy, use the loop to pull the terms from the 'partstype' taxonomy for each individual part, dump these into an array and then echo that, and have each term link to that part type: my php skills are woeful, I am literally just beginning so I can't even begin to approach this without at least a starting point. If this isn't possible, let me know, at least I can stop banging my head on this brick wall! Thanks!


title: Add Useragent to the body class?

text: I'm looking for a way to add body class depending on the User Agent of the client with php. I'm looking to implement it this way: **page.php:** `<body id="front" <?php ( function_exists ( 'body_class' ) : body_class($classes) ? NULL ); ?> >` Or by using adding it to the functions.php file FYI: The whole purpose of this is to sniff out particular mobile styles and disable javascript for the some mobile user-agents. _p.s. I'm not looking for a mobile plugin._ _p.p.s. no, i'm not interested in using a mobile theme._


title: Random post slugs cut off from original and underscores not converted to hyphens

text: I am having a serious problem right now. Our business website just crashed and almost every single page has stopped working. I am in the process of restoring the backup right now but would like any suggestions or tips on what could cause the type of behavior we are experiencing. Our permalink structure is set to "post-name" it always has been. After getting a bunch of 404's saying page not found I started digging into what could be causing the issue. After comparing the links that were in menus and on the pages that were returning 404's I found the page inside our admin interface and looked at the slug. I noticed that for example our post name would be "10 cats sitting on a couch" and the link returning 404 would be "http://example.com/cats/10-cats-sitting-on-a-couch" well now the slug reads "sitting on a couch". Some how the beginning of the slug was removed. Another example would be the underscores. I know that it is bad practice to use underscores but this was done before my time at the company. Normally a link containing underscores would automatically be stripped of underscores and replaced with hyphens. That is not the case any longer. So if I have a link on a page that reads "http://example.com/cats_in_pajamas" wordpress would strip the underscores and replace with hyphens so then the url would read "http://example.com/cats-in-pajamas" Now it just returns 404. Everything was working fine yesterday and no one to my knowledge has touched the website since. There has not been any plugins installed, updated or removed either. Our website contains approximately 1000 pages. I am wondering if there is a limitation when it comes to wordpress. I know that some very large sites operate on it so I am doubting this is the issue. I know that the way the wordpress navigation menu was coded it presents problems when you have a very large menu system trying to be submitted because it runs out of the maximum available variables enabled by PHP's default configuration.


title: I want my wordpress loop to only display posts of the standard format

text: I currently have the following php code for the content loop on my homepage.               <?php             if ( have_posts() ) :                 // Start the Loop.                 while ( have_posts() ) : the_post();                          get_template_part( 'content', get_post_format()  );                      endwhile;                      twentyfourteen_paging_nav();                  else :                      get_template_part( 'content', 'none' );                  endif;         ?>      I want to know how I can specifically select one post format. I want the loop to only display posts of the standard post format.


title: PHP Notice: Undefined offset: 0

text: I receive the following php notice               PHP Notice:  Undefined offset: 0      Here is a sample of what causes the error.               $file = $_SERVER['DOCUMENT_ROOT']."/savedposts/edited".$post_id.".txt";          $saved_content = file_get_contents($_SERVER['DOCUMENT_ROOT']."/savedposts/".$post_id.".txt");     $cct = 0;     $contexttext = array();     for ($i = 0; $i < strlen($saved_content); $i++) {         if (substr($saved_content, $i, 9) == "[Context]") {             $i = $i + 9;             while (substr($saved_content, $i, 10) !== "[/Context]") {                 $contexttext[$cct] .= substr($saved_content, $i, 1);                 $i++;             }          $cct++;         }     }      The error is on this line               $contexttext[$cct] .= substr($saved_content, $i, 1);      How to fix the notice.


title: Adding instant search to wordpress page

text: I'm new to the site and to web development in general. I have a domain name, a hosting site, and wordpress installed. That took me most of a day. Now I'm trying to add this functionality to my site http://www.9lessons.info/2010/09/youtube-instant-search-with-jquery-and.html as a proof of concept before heavily modifying it. The problem is that while I can paste that code into an HTML file and run it perfectly, I can't get my wordpress site to fire it off within a page no matter what I try. After spending a good 6 hours banging my head around with things like child templates, the function.php file, etc. etc. I still can't get it working. What am I missing?


title: Send an extra parameter with xml-rpc login?

text: New to xml-rpc with wordpress. I am trying to add a 3rd login parameter for security reasons to the xml-rpc connection. As it stands the default login only accepts a username and password. On our actual site I have added a "agent id" which is for internal employees and acts as an extra security layer. Is there a way to send something like an "agent id" so the request includes username, password, and agent id from xml-rpc that will make the login validate? If possible, please include a brief sample and explanation.


title: (updated) How to add AJAX error handling to a (fully) custom registration form?

text:
**Update 2.1:** Okay, after messing around with this some more I remembered that I hadn't included the JS file which was causing the white screen, OOPS! ;) Now the form does not submit the data nor send the email ... also the `error handling` is still not working. * * * I have a registration form that runs on the `wp_create_user` function so that I can limit who registers to my site! I'm now trying to AJAXify it for error handling and a "smoother" and more relaxed user experience. After taking `@Andrew Bartel`'s advice I buckled down and applied myself to "at least try" to move in the right direction. So here's my `updated` issue: for some reason, unknown to me, my page still wants to refresh when the form is submitted .. but when it does it doesn't refresh to the "same page" instead the whole screen goes white with no errors or anything. I'm completely lost! Here are the files/code that I'm working with... **The registration form (custom-uploader.php):**
Register a new user
          <a class="logout" href="<?php echo wp_logout_url( get_permalink() ); ?>">Logout

          <form id="register-form" method="post" action="<?php echo plugins_url( 'register.php', dirname( __FILE__ )); ?>">
             <input type="text" name="user_name" id="user_name" class="input" placeholder="unique username" required>

             <input type="email" name="user_email" id="user_email" class="input" placeholder="email address" required>
                       <?php wp_nonce_field( 'nonceification', 'register_nonce' ); ?>
You will receive an email with a generated password
(which you can change in your "user settings")
         <button type="submit" id="wp-submit" class="btn">Register new user</button>     </form>      **Attempted AJAX file (register.js)**               jQuery.noConflict();          jQuery(function() {              // Get the form.         var form = jQuery('#register-form');              // Get the messages div         var formMessages = jQuery('#form-messages');              // Set up an event listener for the contact form         jQuery(form).submit(function(event) {                      // Stop the browser from submitting the form                 event.preventDefault();                      // Serialize the form data                 var formData = jQuery(form).serialize();                      jQuery.ajax({                         type: 'POST',                         url: jQuery(form).attr('action'),                         data: formData                  }).done(function(response) {                              // Make sure that the form Messages div has the 'success' class                         jQuery(formMessages).removeClass('register-error');                         jQuery(formMessages).addClass('register-success');                              // Set the message text                         jQuery(formMessages).text(response);                              // Clear form                         jQuery('#user_name').val('');                         jQuery('#user_email').val('');                 }).fail(function(data) {                              // Make sure that the formMessages div has the 'error' class                         jQuery(formMessages).removeClass('register-success');                         jQuery(formMessages).addClass('register-error');                              // Set the message text                         if(data.responseText !== '') {                                      jQuery(formMessages).text(data.responseText);                         }else{                                 jQuery(formMessages).text('Oops! An error occurred and your request was not sent.');                         }                 });         });     });      **The actual registration process (register.php)**               <?php          require_once( '/home5/desigoe6/public_html/demo/dominion-skills/wp-load.php' );          $username = $_POST['user_name'];     $email = $_POST['user_email'];          // Verify nonce field     $nonce = $_POST['register_nonce'];     if ( !wp_verify_nonce( $nonce, 'register_nonce' )) {              die();     }          // Sanitize user input data     $username = sanitize_user( $username, $strict = true );     $email = santize_email( $email );          // Validate email format     $email_val = filter_var( $email, FILTER_VALIDATE_EMAIL );          // Check if user's chosen name/email already exists     $user_id = username_exists( $username );     $user_email = email_exists( $email );          // Parse data, if 'good' execute     if ( $user_id && $user_email ) {              http_response_code(400);         echo "Oops! There appears to be an account already with that name and/or email.";         exit;          } elseif ( !$email_val ) {              http_response_code(400);         echo "Please enter a valid email and retry!";         exit;          } else {              // Generate the password and create the user         $password = wp_generate_password( 12, false );         $user_id = wp_create_user( $username, $password, $email );              // Update user         wp_update_user( array( 'ID' => $user_id ));              // Set user role         $user = new WP_User( $user_id );         $user->set_role( 'subscriber' );              // Email user their password         $mail = wp_mail( $email, 'Your new password!', 'Here\'s your new password: ' . $password );              if ( $mail ) {                  http_response_code(200);             echo "Success! Check your email for your password! Logout and use your new username & password.";         } else {                  http_response_code(500);             echo "Um, it looks like there was any error and we failed to receive your request ... if this problem persists please let us know!";         }     }?>      Also, if you see any `other` flaws or "bad practices" being put to use in this, please, let me know ... I'm still trying to wrap my head around how this stuff works. Thanks!


title: Setting two top level domains for multisite

text: Here is my situation: We have a multisite set up for a .com domain with multiple subdomains: en.domain.com, fr.domain.com, es.domain.com, etc. For legal reasons when our visitors come from the European Union we must use a .eu TLD in a way that our site will appear as domain.eu, en.domain.eu, fr.domain.eu etc. and while browsing the site the visitor should see all the pages under the european TLD. (we serve different While pointing a domain to specific directory on the server isn't big of a deal since we use `define('NOBLOGREDIRECT', 'https://domain.com');` obviously the .eu domain currently resolves to the front page .com So my question is Is it possible to map two domain to the same multisite installation while preserving the sub-domain structure and allowing the visitors to browse the network under different TLDs Any help will be highly appreciated.


title: Slashes stripped in ACF

text: Use ACF pluging to save a windows path like this : `c:\users\thanassis\photos` using a text field. The ACF saves this : `c:usersthanassisphotos` as path except the character `\`. If I use this `/` it's ok. I would like to know if it is possible to save the correct path?


title: Setting Post Title via Meta Data returns Auto-draft

text: I've read here and other places about setting a post's title based on it's metadata. Unfortunately I'm unable to get it working and I'm hoping someone else can point me in the proper direction or explain where I'm wrong. Here's my code:               function setup_match_title( $data, $postarr ) {         if ( $data['post_type'] == 'matches' && $data['post_title'] == '' ) :                  $a = get_the_title( get_post_meta( $postarr['ID'], 'away_name', true ) );             $h = get_the_title( get_post_meta( $postarr['ID'], 'home_name', true ) );                  $data['post_title'] = $a . ' vs ' . $h;              endif;              return $data;     }          add_filter( 'wp_insert_post_data', 'setup_match_title', 99, 2 );      _The home and away team metaboxes are select boxes populated with a list of "teams" post_type that stores the team's post_id._ When I publish a new "match", my post title reads "Auto draft vs Auto draft". My guess is since nothing is in the database when `get_post_meta()` runs, it returns Auto Draft. I believe that because if I go back into the post, empty the title (so it passes the initial if statement) and Update it, the proper title is set. What am I doing wrong? Is there any way to get the value of a select box at runtime using `get_post_meta()`?


title: Random post, page inside post loop problem

text:
I want to display a random page in the index page of my site and it's all good with that.The problem is that before the post I want to display a page depending in which category the post is posted.Website is about world countries so before the post I want to display a description of the country, some pictures and stuff. The problem is that when I load a page, the post is no longer displayed(2pages are), so after loading a page I have to reset query.After that something bad happens and not 1 random post is displayed, but all the posts. The code:               <?php global $more; $more = -1; //declare and set $more before The Loop ?>                         <?php     query_posts(array('orderby' => 'rand', 'showposts' => 1));     if (have_posts()) :     while (have_posts()) : the_post(); ?>                                                  <?php     if(in_category('afghanistan')) {     $recent = new WP_Query("pagename=asia/afganistanas"); while($recent->have_posts()) : $recent->the_post();?>
<?php the_title(); ?>
            <?php the_content(); ?>     <?php endwhile;     }     elseif(in_category('albania')) {     $recent = new WP_Query("pagename=europe/albania"); while($recent->have_posts()) : $recent->the_post();?>
<?php the_title(); ?>
            <?php the_content(); ?>     <?php endwhile;     }     else {     echo "Error!";     }     ?>     <?php wp_reset_query(); ?>

<?php the_title(); ?>
               <?php the_content(); ?>                    <?php endwhile;     endif; ?>


title: Reblog wordpress.com posts on self hosted

text: I'm currently collaborating to a wordress.com blog and would like to use the reblog feature to mirror my posts there to my main blog that is a self hosted wordpress installation. My understanding is that this is only possible within wordpress.com so I searched for some plugins to accomplish this and the closest I came to it is the "Press This" feature, but it's not a good solution because it's mostly copying and pasting the text from the other post and it seems to fail to import links, youtube videos and other things. Is there some way to do this?


title: custom query for both category and pages using global $wpdb;

text: I have a custom query returning categories, but I also need to return some pages with a particular post ids. How would I add those? They obviously have no taxonomy and are page post types. Below is my query so far:               protected function _getPostByCategory($category) {     global $wpdb;          $result = $wpdb->get_results(" SELECT * FROM $wpdb->posts     LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)     LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)     LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)     LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)     WHERE $wpdb->terms.name = '$category'     AND $wpdb->term_taxonomy.taxonomy = 'category'     AND $wpdb->posts.post_status = 'publish'     AND $wpdb->posts.post_type = 'post'     GROUP BY $wpdb->posts.ID     ORDER BY $wpdb->posts.post_date DESC");


title: Wordpress: Notice:Object of class WP_Query could not be converted to int in on line

text:
I am facing issue in debug mode with wordpress. In my featured slider getting error `Notice: Object of class WP_Query could not be converted to int in on line` I am using below code for my slider               <div id="<?php slider_class() //Theme function ?>" class="clearfix">                       <div id="slides-wrapper" <?php slider_wrapper_class() //Theme function ?>>                          <div id="slides" class="<?php slides_class() //Theme function ?> clearfix">                                  <div class="slides_container <?php slides_class() //Theme function ?>">                          <?php                     $featuredPosts = new WP_Query();                     $featuredPosts->query('showposts='.get_option('mp_slides_no').'&category_name='.get_option('mp_featured_cat').'');                          for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides                     while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts                     ?>                          <?php if (get_option('mp_slides_content') === "content_s") { ?>
                                                  <?php mp_thumb('featured-thumbnail','featured-slider-thumbnail','480'); //Theme function  ?>

<a href="<?php the_permalink(); ?>"><?php echo substr($post->post_title,0,50); // short title ?>...
                                  <?php the_excerpt(); ?>
                             <a href="<?php the_permalink(); ?>" class="featured-readmore clearfix">Read more<img src="<?php bloginfo('template_directory'); ?>/images/button-arrow.png" alt="readmore" width="24" height="24" />

                                               <?php } elseif (get_option('mp_slides_content') === "image_s") { ?>
                                                  <?php if (get_option('mp_slides_style') === "fixed") { ?>                                  <?php mp_thumb('featured-thumbnail','featured-slider-image920','920'); //Theme function  ?>                              <?php } else { ?>                                  <?php mp_thumb('featured-thumbnail','featured-slider-image960','960'); //Theme function  ?>                              <?php } ?>
                                                                                <?php } ?>                          <?php endwhile;                     } // end for() loop number 2                     ?>

      `//theme function` are nothing but switching the class for style --[ Resolved Code ]------------------------------------------------------------------- As I am new to php I didn't realized I am using two loop at the same time for and while. With Manny Fleurmond's comment my mind just clicked and I use below code and it just works fine with me. Also changed post_per_page option as m0r7if3r said. Please tell me if anything is wrong in this code.               $temp = $wp_query;                     $wp_query = null;                     $wp_query = new WP_Query();                     $wp_query->query('category_name='.get_option('mp_featured_cat').'&posts_per_page='.get_option('mp_slides_no').'');                                    while ( $wp_query->have_posts() ) : $wp_query->the_post(); // loop for posts                     ?>


title: Conditional for Post Format

text:
I want to to show a specific content on the top of each post (on single page) depending of the post-type. If it's `normal`, show something, if it's `gallery`, show another. By now the code is like this:               <?php         if  (has_post_format( 'post-format-normal' , $post_id )) {             <div class="post-image-section section" style="background-image: url(<?php echo $single_post_image_url ?>);">                 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">                 <?php the_post_thumbnail('single-post-image'); ?>                 <?php if ( !empty(get_post(get_post_thumbnail_id())->post_excerpt) ) : ?>

<?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>

                 <?php endif; ?>
         } elseif ( has_post_format( 'post-format-gallery' , $post_id )) {             <?php flexslider('index-post-image'); ?>                     }     ?>      But it's not working, looks like there is a typing error on the code... I want that if the post type is `gallery`, to show the flexslider, and if it's `normal`, show the post_thumbnail... How to achieve that?


title: How to list post as buch of category, and all of them

text: I like my homepage not to list only one category, but to list all category, group by post. Here is the request : Cat   * 1   * 2    * 3    * 4    * 5 and the post will be : post   * 1 (cat=2)   * 2(cat=2)   * 3(cat=1)   * 4(cat=3)   * 5(cat=4)   * 6(cat=4)   * 7(cat=4)   * 8(cat=4)   * 9(cat=5) i like to list cat : 5,2,4,3,1 and when listing them, all the post from cat 5, then all the post from cat 2, and so on So the result will be post :   * 9   * 1   * 2   * 5   * 6   * 7   * 8   * 4   * 3 hope the example is clear enough to let you help me... thanks in advance


title: Internet Explorer "Security Information" on every page in https site

text: My site is using a short vanity URL and https (for admin logins). This is working across all of the custom theme pages in every browser except Internet Explorer. Specifically in IE7, every page I visit in the site presents this warning message: > Security Information This page contains both secure and non-secure items. Do > you want to display the nonsecure items? Do you think the site being https is causing this? Anything I can do to fix this?


title: Upgrade to 3.3.2 return a blank admin page

text: When I attempt to upgrade my wordpress site to the latest version (3.3.2) thru the auto update in the dashboard it goes thru the process and at the end says there is an error when the site goes into maintenance mode. When I reverse all the changes and look for the maintenance file to delete I can't locate it at all. I then try to do a manual update and I then get a blank screen when attempting to log into the back end of the site. I also disable all plugins before I attempt to upload updated files. Any suggestions as to what might be wrong?


title: Hide Pages on Edit Pages based on Capability (edit_others_pages)?

text: Currently, WordPress does a great job displaying pages on the Edit Pages admin area for users with the capability edit_others_pages. However, if a user has edit_others_pages and has not yet authored any pages, WordPress defaults to listing all the pages removing edit actions, etc. However, I would like WordPress to display no pages if a person hasn't authored any pages. I've tried writing some code into pre_get_posts, but it doesn't seem to work.               add_action( 'pre_get_posts', 'wps_admin_exclude_pages' );     function wps_admin_exclude_pages( $query ) {         if( ! is_admin() )             return $query;              global $pagenow, $current_user;         if( 'edit.php' == $pagenow && 'page' == get_query_var( 'post_type' ) && ! current_user_can( 'edit_others_pages' ) )             $query->set( 'post_author', $current_user->ID );              return $query;     }


title: 'qTranslate slug with widget' plugin works with posts but not pages

text: I'm using 'qTranslate slug with widget' plugin which is great, however, I'm stuck on one thing. If I set permalinks as /%post_id%/%postname%/ as recommended by plugin author - this works with my pages perfectly BUT my posts URL would then include post- id/pretty-permalink e.g. www.website.com/123/webpage (I don't want the post-id to appear). If I set my permalinks to /%postname%/, my posts URL appear perfect BUT my pages return a 404 (the pages exist - it doesn't to be working with qTranslate slug). (I'm working on wp3.0.5) I've searched for answers and seems a couple of people are also having same problem. Anyone also experienced this and found a solution? Thanks in advance for any tips!


title: Wordpress hook before inserting post into database

text: I need to do check the inserted post for certain keywords and perform some functions depending on the keywords found. is there a wordpress hook that executes "just before the post is inserted into the database" ? Or will i have to modify wordpress core ? Also, i will need to prevent the post from being inserted into the database if some keywords are found. is this something that can be done with a hook ? Or will a core modification be needed ?


title: Insert Ad Code in the Middle of a Post

text: I want to insert an ad code in the middle of a post via `functions.php`. I found several links but either they don't use `functions.php` or don't insert the code in the middle. Can anyone tell me how to do this? Also, I don't want to use a plugin.


title: Trouble installing bbpress

text: I'm trying to install bbpress 2.1 on wordpress 3.4.1 and I am running into some difficulties. When i try to go to /forums (which is my "Forums base" setting) I get a 404 page. I have tried resetting my permalinks. (set to default, saved, and set it back to %postname%) but no luck The other problem I'm running into is that when bbpress is active my homepage starts using `page.php` instead of `index.php`. Completely puzzled on this one.


title: Including facebook.php in a wordpress page template?

text:
I was wondering if I can include Facebook's php sdk file into a wordpress page template ? For example in page.php:               <?php get_header(); ?>              <?php get_sidebar(); ?>

                                <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                                  <?php the_content(); ?>                              <?php endwhile; ?>

                  <?php get_footer(); ?>      Can i attempt to include facebook.php like this:               <?php get_header(); ?>              <?php get_sidebar(); ?>                   <?php                   session_start();         echo "pass sds1";         require_once TEMPLATEPATH.'/include/facebook.php';         echo "pass";         $config = array(             "appId" => "XXXX",             "secret" => "XXXX");              $fb = new Facebook($config);         echo $fb;         $user = $fb->getUser();         echo $user;         ?>

                                <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                                  <?php the_content(); ?>                              <?php endwhile; ?>

                  <?php get_footer(); ?>      I've tried doing the above, but the `echo "pass";` was not executed, this means that the `require_once TEMPLATEPATH.'/include/facebook.php';` line has failed. Can anyone advise me on how to achieve this ? Thanks!


title: Static front page displaying twice

text: I am using a free SM theme (estate agent) on my WordPress site. The theme allows for setting a static front page, which I did (the page is called 'events', and when I set it as home page its permalink became simply `www.example.com`). The problem is the page is now displayed twice. Here is my website.


title: Which hook should be used in this case?

text: I'm using the enter_title_here filter to modify the 'Enter title here' text in a custom post type, question is what hook should I use to trigger this function? I have used admin_enqueue_script as a test and it worked, but I think there is a better hook since this is not really a script.                   function print_scripts() {          $screen = get_current_screen();         if ( 'post' === $screen->base && 'myposttype' === $screen->post_type ) {             wp_enqueue_style( 'styles', WP_CSS . 'styles.css' );             // filter used here             add_filter( 'enter_title_here', function() { _e("Enter name here"); } );         }           }              add_action( 'admin_enqueue_scripts', 'print_scripts' );


title: How do I disable a plugin enforced by my host (in mu-plugins)?

text: My host makes mandatory two plugins which get automatic updates under mu- plugins folder. Is there a way I can disable them with some trick, for example with a plugin folder of the same name under my local plugins folder or by duplicating some function and make them empty?


title: Best way to count visitors?

text: I want to count how many people visit my wordpress-website an want to know the following data:   * visitors per day/week/month/year (with history)   * which subpage/article attracts the most visitors Is there a plugin that can do that?


title: Is it possible to have WordPress not recognize category URLs?

text: I don't want to support Categories in my WordPress site. I know I can have an empty category.php page to cater for users using a URL to directly query the default Category (/category/Uncategorized), but I was wondering if there's a way to shut off WordPress's recognition of the category URLs, so that any attempt to access them would direct to the 404 page? Thanks.


title: Check if page/post has any anchors that link to an image jpg/gif/png

text: What I'm aiming to do is add fancybox to a site I'm developing, but I only want to enqueue the JS/CSS etc if the page/post needs it. My thoughts are that I would need to check all the anchor tags on the post or page , and if the anchor tags link to any form of image (jpg, png,gif) then I will enqueue the necessary assets. Does this seem like the correct approach? Is this a job for regex, somehow applied to a filter of the_content? I'm ok with everything else, just need the test. The code below adds a `.fancybox` class to all the anchors that link to the specified filetypes so maybe I can somehow check for the class name? PS I don't want to use a plugin to load fancybox, prefer to do this myself.               jQuery("a[href$='.jpg'],a[href$='.png'],a[href$='.gif']").fancybox();      **Update** : this is a simple check that I have so far which will check the content for anchors. Just need to adapt for having a class name and I think I'm there, seems to work ok.               function content_image_check( $content ) {          if( strpos( $content, "<a" ) ) {        echo 'yes';     } else {        echo 'no';      }          return $content;     }          add_filter('the_content', 'content_image_check');       **Update 4** I'm using a XPath query. This is the closest I've gotten so far. It will enqueue the css and js only if there's anchors on the page with images inside them. I'd like to modify the query so it can find the anchors with a class of 'fancybox' but For some reason the query cannot see the 'fancybox' class name being added from jQuery when I try with `$hrefs = $xp->query("//a/img/../@class['fancybox']");` The other option would be to sort by anchors with an href that has a filename that ends in .jpg, .gif, png. I'd be happy with that.               function content_image_check( $content ) {               $dom = new DOMDocument();     $dom->loadHTML($content);          $xp = new DOMXPath( $dom );     $hrefs = $xp->query("//a/img/../@href");               $count = $hrefs->length;     print_r( $count);          return $content;     }          if ( $count ) {         wp_enqueue_script( 'fancybox' ); // js         wp_enqueue_style( 'fancybox' ); // css     }          add_filter('the_content', 'content_image_check');       I've obviously registered the css and js elsewhere and only enqueue it when needed.


title: Wordpress Plugin to for moving home page slideshow?

text: How can I create a moving skideshow similar to the one on this site? Is there a plugin doing this already? I have searching using the "moving slideshow" keywords. Any tips? Many thanks.


title: How do I exclude portrait pictures from the nextgen gallery sidebar widget?

text: I have a gallery that contains both landscape and portrait pictures and want the gallery to be displayed in the wordpress sidebar. The problem is that the thumbnails of the portraits are scaled into landscape format which is unacceptable. Is there a way to exclude portrait pictures? Or is there a way to keep the ratio for such thumbnails in the sidebar widget?


title: Slash is being stripped in my post_name when using wp_insert_post

text: I want a permalink with slashes : e.g. http://mysite.com/keyword1/keyword2/mypage.html I have put it in the param "post_name" in wp_insert_post but the slashes are stripped, so the result is http://mysite.com/keyword1keywordmypage-html (the dot is also replaced by -) the keyword1, keyword2 are arbitrary values extracted from the post's content how can i also add the .html without it being replaced


title: How to use is_feed() to target a category feed?

text: `is_feed` (one of the many conditional tags) can be used to determine if the current query is for a feed. But how do I use it to target all category feeds? (or tag or custom taxonomy feeds for that matter) This doesn't seem right:               if (is_category()) {              if (is_feed()) {             // Code Goes here         }          }      And I have no clue as to whatelse I'd try.


title: Filter for post_thumbnail: link to small src and add data-attribute

text: I wonder how I can link manually to the smallest filesize for `the_post_thumbnail()` within its filter function …               add_filter( 'post_thumbnail_html', 'post_thumbnail_html', 10, 3 );          function post_thumbnail_html( $html, $post_id, $post_image_id ) {              $html = '' . '' . '';              return $html;          }      So now my image src is just the post_id (e.g. 38). How can I link to the smallest filesize possible and add another data-attribute that links to the largest file? My output should finally look like this …                     Thank you in advance! edit/update: I'd love to do the same for images inside `the_content()`. Any idea how to apply the same thing to normal images in posts. The src should always hold the smallest size wordpress creates and the data attribute should link to the largest filesize.


title: How do you format the date as a two digit year? (ex. "10.12.10" instead of "10.12.2010")

text: I did a pretty thorough search and found a couple of closed (and unanswered) topics on the WP forums. Does anyone know if this is possible? The codex doesn't specify this as an option. Thanks!


title: get current user not working

text:
I was trying this code to get current user info, but showing nothing. My WordPress version is 3.3.1               <?php         wp_get_current_user();         /**          * @example Safe usage: $current_user = wp_get_current_user();          * if ( !($current_user instanceof WP_User) )          *     return;          */         echo 'Username: ' . $current_user->user_login . '
';         echo 'User email: ' . $current_user->user_email . '
';         echo 'User first name: ' . $current_user->user_firstname . '
';         echo 'User last name: ' . $current_user->user_lastname . '
';         echo 'User display name: ' . $current_user->display_name . '
';         echo 'User ID: ' . $current_user->ID . '
';     ?>       **The output is:** Username: User email: User first name: User last name: User display name: User ID:


title: Uploading PDF files from the front-end

text: I am working on a Wordpress site that has a custom front-end form for submitting posts. I need to add a field in the form to allow users upload a single PDF file along with the post. How can I achieve this?


title: How to remove a parent theme template from Quick Edit?

text: I was looking for a way to hide the parent theme's templates and found this answer which works perfectly to remove the parent templates from the pages edit screen - How to *remove* a parent theme page template from a child theme?. I don't want the parent templates that I've removed to show anywhere in admin, however they still appear in the dropdown box labeled "Template" on WP Admin > Pages > All Pages in the "QUICK EDIT" section. Does anyone know of a way to do this?


title: Code to make a post sticky

text: How is it possible to upgrade a post to make it sticky directly from code, not by admin area? Is it possible through a code like:               update_post_meta($post_id, $meta_key, $meta_value, $prev_value);      In this case, the $post_id is known, but the $meta_key? Thank you in advance for your answers


title: WP app getting confused about posts and pages

text: I wanted to use the Wordpress iPad app (3.1.1) for my new blog. Somehow the app seems to be a little bit confused for me. It shows some of my posts as pages and vice versa. It does show a lot of old post, bot none of the newer ones. I have no idea why that is. On my server I have the following WP setup:   * Wordpress 3.4.1   * Theme: Twentyeleven   * Active Plugins: ** Akismet ** Jetpack That's it. The only thing I consider noteworthy besides those facts is that I've imported some of my old blog posts (from BlogEngine.net) via BlogML when I started my new WP blog a few weeks ago. My page seems to have an issue with the RSS feed as well. Once I add the feed to a reader it downloads all the articles properly. But new posts never make it through. I'm not sure if that helps diagnosing the other problem. Anyway, thanks a lot!   –f -- I'm re-posting this here since I did not get any feedback on the Wordpress forum yet. **Update** I posted the screenshots requested by Damien to my website (to make it funny: as a WP page ;)). The page you see is missing on the screenshots. On the website it show's up as expected. The app does not show it at all. So here it is: http://blog.flohei.de/wordpress-issues/


title: WP_Query vs get_posts

text: I have read a **number** of **questions** on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of secondary loops and only use get_posts if I need the results returned in an array, or to put it another way is the main difference between the two the array vs object return, or is there some other major factor I should be aware of?


title: Is there any need to use both wp_reset_postdata and wp_reset_query together?

text: Is there any need to use both `wp_reset_postdata()` and `wp_reset_query()` together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query :                wp_reset_postdata();      wp_reset_query();


title: Auto close (hide) custom metabox / set default state

text:
I am using the WordPress function `add_meta_box()` to add my own custom metabox. So how can I auto close/hide on page open ? Currently, I just add a CSS class `closed` to metabox's `<div>` element via jQuery like so: **HTML :** (example)

      **jQuery :**               $("#my_metabox.postbox").addClass("closed");      But is there a WordPress function to do this ?


title: Include a page template along with add_theme_support()

text: I'm not even sure this is possible but before I start thinking up crazy solutions, I'll see if there is a WordPress way to do it. Here's the deal. I have a timeline jQuery plugin all set up on WordPress and I want it to be callable in a child theme through the add_theme_support method:               add_theme_support( 'timeline' );      Call it an obsession with modular design. I've probably read too much Tadlock for any one man's sanity but it's working for me. So the first part works just fine. I've got the stylesheet & js file all conditionally enqueued if theme support has been specified and the one nagging problem is that I can't conditionally include a new page template. Having a "Timeline" template show up when timeline support is disabled is just bad UX design. So here's the question - is there a filter method for conditionally inserting a global page template from outside of the usual locations? For example, if I were to put my page template in /library/inc/conditionals/page-timeline.php (effectively hiding it from WordPress), how could I filter it back into the template list on a page? If I can figure that out, I can add the filter to my add_theme_support function, angels will fly, trumpets will sound, and I will be happy. The problem is that I'm not familiar with that particular drop box or how to invoke it in an unusual way. Thanks for your brains! (not-in-a-zombie-way)


title: Add link at the end of wp_nav_menu

text: I need to add a conditional menu item such as "/at" or "/de" or "/ch" in the `wp_nav_menu`. Since the link is conditional (based on the country the website is being viewed), it can't be added from the backend but instead has to be hardcoded. How do I add this new conditional link at the end of what the `wp_nav_menu` is populating? Thank you.


title: How to change the standard width of a page

text: How can I expand the standard width of a page in a premium theme? It seems to be fixed to 800px, and I don't know where to start.


title: Rewriting custom post type permalinks gives 404

text: I am using this code in my functions file to be able to include a post ID in my permalinks for a custom post type. But I am getting a 404 error when I attempt to preview view any of the posts of that type.               add_filter('post_type_link', 'wpse33551_post_type_link', 1, 3);          function wpse33551_post_type_link( $link, $post = 0 ){         if ( $post->post_type == 'space_listing' ){             return home_url( 'space/' . $post->ID . '/'. $post->post_name );         } else {             return $link;         }     }          add_action( 'init', 'wpse33551_rewrites_init' );          function wpse33551_rewrites_init(){         add_rewrite_rule(             'space_listing/([0-9]+)?$',             'index.php?post_type=space_listing&p=$matches[1]',             'top' );     }      I have re-saved my settings->permalinks page multiple times, which hasn't worked. Here is the code for my registered post type:               add_action('init', 'cptui_register_my_cpt_space_listing');     function cptui_register_my_cpt_space_listing() {     register_post_type('space_listing', array(     'label' => 'Space Listings',     'description' => '',     'public' => true,     'show_ui' => true,     'show_in_menu' => true,     'capability_type' => 'post',     'map_meta_cap' => true,     'hierarchical' => false,     'rewrite' => array('slug' => 'space_listing', 'with_front' => true),     'query_var' => true,     'has_archive' => true,     'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),     'taxonomies' => array('space-features'),     'labels' => array (       'name' => 'Space Listings',       'singular_name' => 'Space Listing',       'menu_name' => 'Space Listings',       'add_new' => 'Add Space Listing',       'add_new_item' => 'Add New Space Listing',       'edit' => 'Edit',       'edit_item' => 'Edit Space Listing',       'new_item' => 'New Space Listing',       'view' => 'View Space Listing',       'view_item' => 'View Space Listing',       'search_items' => 'Search Space Listings',       'not_found' => 'No Space Listings Found',       'not_found_in_trash' => 'No Space Listings Found in Trash',       'parent' => 'Parent Space Listing',     )     ) ); }      Can anyone see what might be the problem?


title: Make individual attachments private?

text: Is there any way to make individual attachments private similar to how a post can be made private? I've looked through various plugins but none really seem to do the job. They usually make all attachments private which I do not want.


title: display order of connections

text: Is there a way to control the order in which connections are displayed ? I've got a Articles => Books connection so that in each article I can quote a number of books. I want to display the quoted books in the footnotes of the article. Currently, if I create say three books connections and then display them at the bottom of my article, I will get them in reverse order. Can I change that ?


title: Subnav menu - adapt to show the same on parent, child & grandchildren pages?

text: I found this very useful code at the wp codex, it basically lists out the parent, child and grandchild pages, I'm using it in my sidebar and it works well for the parent and children pages, but when you go to a grandchild page, the menu changes and it now only shows the child/grandchild, instead of the same menu on the parent & child pages. how can i make it show the same on all the pages? Also i'd like the parent title to be an actual link rather than just text and I can't seem to figure that out. help is greatly appreciated!!                           <?php                      if($post->post_parent) {                     $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");                     $titlenamer = get_the_title($post->post_parent) ;                     }                          else {                     $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");                     $titlenamer = get_the_title($post->ID);                     }                     if ($children) { ?>                          <h2> <?php echo $titlenamer; ?> </h2>                     <ul>                     <?php echo $children; ?>                     </ul>                 <?php } ?>


title: Why is the text editor linked to the visual editor?

text: When I erase something in the "visual" tab the code from the "text" tab is getting erased too. When I write something in the visual tab it's appearing in the text tab. Somehow, they both got linked together and it's forcing me to have the same thing in each tab. What's going on?


title: How do I edit a links published date?

text: I mean the links in in the admin panel. There is no option to edit published date.![enter image description here](http://i.stack.imgur.com/XFoCz.png) EDIT: added screenshot of link. Please don't down vote me, I know how to edit posts published date.


title: WordPress Plugin for One-Time Event Registration?

text: I am building a website for a charity event and i would like for people to register for this event. The form should contain name, email and other custom questions. Also I would like a page where to list the persons registered. I was thinking of using the user system + a plugin for listing the user list. What plugins would you use? Thanks.


title: Creating Custom Roles for use on a WordPress Multi-site Instance?

text: We have a large site that consists of a number of smaller websites. We are looking at replacing our current CMS with WordPress. The only problem is that we need to create a custom role (kind of in between Editor and Administrator) and make it available to all sites in a multi-site network. I have looked at a couple of plugins that work well on a single site, but none seem to work on multi-site. Any recommendations? This is the closest thing I have found:   * WPMU Roles and Capabilities Hacks Plugin


title: Rewriting a date hierarchy into a 'yyyy-mm-dd' slug

text: I am building a magazine website with an `issue` custom post type. The slugs for each issue follow the format `YYYY-MM-DD` according to the issue's publish date. Currently the permalinks are set up as `http://host/magazine/2014-06-08` but I would like them to be accessed through the URL `http://host/magazine/2014/06/08`. Here is what I'm currently doing in my `functions.php`:               $issue_structure = '/magazine/%issue%';     $wp_rewrite->add_rewrite_tag("%issue%", '(\d{4}-\d{2}-\d{2})', "issue=");     $wp_rewrite->add_permastruct('issue', $issue_structure, false);      I tried adding this to my .htaccess file:   `RewriteRule ^magazine/(\d{4})/(\d{2})/(\d{2}) /magazine/$1-$2-$3 [QSA,L]` And I also tried added this to my WP_Rewrite rules:   `add_rewrite_rule('magazine/(\d{4})/(\d{2})/(\d{2})', 'magazine/$matches[1]-$matches[2]-$matches[3]', 'top');` Neither of those approaches have worked, either separately or in combination. And I was careful to flush my rewrite rules. In fact, there's no evidence of that `add_rewrite_rule` call in my Rewrite Rules Inspector list, so I suspect I'm not using it correctly. Another (hacky) thing I tried was manually tweaking the `post_name` field in the database to be `2014/06/08` and switching up the rewrite tag to be `$wp_rewrite->add_rewrite_tag("%issue%", '(\d{4}/\d{2}/\d{2})', "issue=");` but that didn't work either. What else should I try?


title: Related posts widget or plugin needed

text: I'm looking for something like they are using here: http://www.jennyreviews.com/as-seen-on-tv/triple-joint-formula/ Look under "Related Product Reviews" I checked the source but could not find the plugin code listed. Maybe its a widget?


title: List CPT by menu_order with children right after parent

text: I registered a custom post type `drawer` where my posts are ordered using `menu_order`. Each drawer could be a child of another drawer, on a multiple depth (parent > child > child of child > child of child of child...... you get the idea ;)). My code so far looks like that :               $args = array(         'numberposts'     => -1,         'orderby'         => 'menu_order',         'order'           => 'DESC',         'post_type'       => 'drawer',         'post_status'     => 'publish',     );     $drawers = get_posts($args);          foreach ($drawers as $drawer){         $title = get_the_title($drawer->ID);         echo $title . ' (parent : ' . $drawer->post_parent . ')<br>';     }      But I'd like to get the child of a parent post right after the parent post is returned, with the `menu_order` value being used to sort these children too. I get the whole logic : I should somehow create a "nested" loop where I use `get_posts` with the `parent` parameter set to verify & get the sorted children. But because I can have a lot of depth with this parent/child behaviour, I don't think that's the most efficient way and I can't get my mind to create a "nested" loop. To visualize what I need : look at this image http://img.saika.li/Opkq to understand the real order that I'd like to get (blue titles) compared to what I get for now. I hope someone has a solution !


title: Capability to edit own posts and not others

text: What is the capability that let users to edit their own posts and not others? I am trying to enable the post authors to avail a plugin function only on the posts they own. The permission to access the option should be only to that particular post authors and even the editors shouldn't have access. Next to the post authors, only the administrator should have the access. The plugin's code has:               function init()     {         // must be logged in         if( is_user_logged_in() )         {             // actions             add_action('admin_head', array($this,'admin_head'));             add_action('admin_menu', array($this,'admin_menu'));                       add_action('wp_enqueue_scripts', array($this,'wp_enqueue_scripts'));             add_action('wp_head', array($this,'wp_head'));             add_action('wp_footer', array($this,'wp_footer'));             add_action('wp_ajax_live_edit_update_width', array($this, 'ajax_update_width'));         }     }      I have edited the plugin file to change the capabilities(line 79).                   function init()         {             // must be logged in     if( is_user_logged_in() && current_user_can('author') || current_user_can('administrator'))             {                 // actions                 add_action('admin_head', array($this,'admin_head'));                 add_action('admin_menu', array($this,'admin_menu'));                           add_action('wp_enqueue_scripts', array($this,'wp_enqueue_scripts'));                 add_action('wp_head', array($this,'wp_head'));                 add_action('wp_footer', array($this,'wp_footer'));                 add_action('wp_ajax_live_edit_update_width', array($this, 'ajax_update_width'));             }         }      Now, only the post authors and administrators have access to it. But I want to replace `current_user_can('author')` to a capability which lets the author's to edit their own post and not others. The capabilities like `edit_posts` or `edit_published_posts` gives access to all the posts. Could any one tell me about a capability which enable users to edit their own posts and not others? Also let me know if the way I used is right. `if( is_user_logged_in() && current_user_can('author') || current_user_can('administrator'))` Here is the plugin's code: http://pastebin.com/m1E9QthM. Link to the original plugin is- http://wordpress.org/support/plugin/live-edit


title: Differentiate Parent & Child of Custom Taxonomy

text: I use Custom Taxonomy "Artists" to differentiate between "Albums" (Parent Taxonomy) and "Albums" (belonging to an Artist, Child Taxonomy). I am showing my taxonomy on posts for users to see which Artist and Album is associated with each post. My code is working fine in some cases, but in others, it doesn't differentiate correctly between Parent (Artists) and Child (Album) (Children show as Parents). Here is what I'm using at the moment. How can I improve it to avoid my issue?               $_terms = wp_get_post_terms($post->ID, 'hhie_artists');        if (!empty ($_terms)):           echo "In this Article: ";           echo "Artist/s: ";     foreach ($_terms as $_term) {        if ($_term->parent == 0) //check for parent terms only           '' . $_term->name . ' | ';             if ($_term->parent > 0) //check for children           echo 'Album: ' . $_term->name . '';        }     endif;`      Note: There will be a max of one album per post. **EDIT:** Sorry for lack of clarity. I get things like this returned:   Artist/s: Album: A Year In The Life Of Oscar The SlouchRamson Badbonez | (Should be: Artist/s: Ramson Badbonez | Album: A Year In The Life Of Oscar The Slouch) This doesn't always happen though. Sometimes it shows correctly. In the case of multiple artists: Artist/s: Album: Dabbla JehstHeavy Ear Play (Should be: Artist/s: Dabbla Jehst | Album: Heavy Ear Play)


title: Change top level menu item to point to custom submenu item

text: I'm using a plugin called CMS Page Order http://wordpress.org/extend/plugins/cms-page-order/ (Now referred to as CPO) It's pretty simple, the said plugin adds a new item to the submenu of every custom post type. The menu item leads to a page where you can reorder the posts of the certain post type. I've added so that you can create new posts directly from this view, so basically it's like the default edit post view in Wordpress, but you can reorder your posts aswell. This renders the usual post edit page pretty useless. **So my question is** , is there a way for me to remove the "All _post type_ 's" submenu item (`edit.php?post_type=nameofposttype`) replacing it with this menu item created by CPO while also making the top level menu item itself point to the page created by CPO. ––– What I've been trying to do is to try to replace the top level menu item with the URL of the submenu item created by CPO using the plugin Admin Menu Editor, but changing the URL via the plugin is not allowed it seems. I then tried moving the CPO menu item to the top of the submenu as I noticed that the top level menu item points to the topmost submenu item (ie "All pages/posts"). That did not work either, as it produces an URL that is erroneous (it makes the top level menu item point to `admin.php?page=order-xxx`) Here's some images to further explain what I mean. ![Here's how the top level item regurlarly behaves](http://i.stack.imgur.com/uLI1c.jpg) Here's how the top level item behaves as default (`edit.php?post_type=xxx`) ![Now here's what happens if I move my page with the special menu handler to the top. The top level item gets a new URL, but it's erroneous](http://i.stack.imgur.com/BlVcQ.jpg) Now here's what happens if I move my page with the special menu handler to the top. The top level item gets a new URL, but it's erroneous (`admin.php?page=order-xxx`) ![Here's the url that the special menu handler page has, the URL that the top level menu item should have](http://i.stack.imgur.com/yVAen.jpg) Here's the URL that the special menu handler page has, the URL that the top level menu item _should_ have (`edit.php?post_type=xxx&page=order-xxx`) So, how can I change the top level menu item to the URL I want?


title: Auto create description in post

text: I want to create a script for when I add a title and an image to a post, and then when i publish, i want it to auto create a description Something like . . . . . You are viewing [title of post]! These are great hairstyle designs in our [category] section. Hope you try this look and feel on your hair today. Ever considered changing it up, you might like this [random post title and link] This would be the body content of the post, In the last part it will select a random post and place his title and link (you might like this [random post title and link]) How can i achieve this using a php script and calling it from the publish button?


title: wordpress - ajax communication

text: This is the first time I do the ajax and I must confess that I am confused. What I want to do is to take the value of 3 Select html to make a request to my database that'll get me a score according to the desired choice. The purpose of using ajax is that I do not want the submit button and I want that when the value of one of my select changes only choose my result in my database changes according to the new value. So the hen I change a value in my select I call a javascript that takes values from my select and pass ajax to my function.php which then makes a request with the values of my Selects function and then returns the result of my request. I have my html in archive page, my .js in external file and my php function is in function.php. My problem is that dont working and i dont know why, i follow 5 tuto and all are different and confuse me. Sorry for my English, this language is not my first language. Now my code look like that: javascript:               function showWidth($) {       // get the value of my 3 html select       var width1 = document.getElementById('width1').value;       var width2 = document.getElementById('width2').value;       var width3 = document.getElementById('width3').value;            if (width1!="aucun" && width2!="aucun" && width3!="aucun") {         $.ajax({           ObjectName.ajaxurl,           data: {             action:'script_handle',             width01 : width1,             width02 : width2,             width03 : width3           },           success:function(data) {             // This outputs the result of the ajax request             document.getElementById("result").innerHTML=console.log(data);           },           error: function(errorThrown){             console.log(errorThrown);           }         });       }     }      PHP (in function.php):               function widthcalculate(){         if( isset($_REQUEST) ) {           $width1 = $_REQUEST['width01'];           $width2 = $_REQUEST['width02'];           $width3 = $_REQUEST['width03'];           // Let's take the data that was sent and do something with it           global $wpdb;           $where = "'".$width1."' AND camber = '".$width2."' AND handrim = '".$width3."'";           $sql = $wpdb->get_results(            "SELECT result FROM mc_widthCalculatorResult WHERE wheel = ".$where.""           );           foreach ($sql as $element) {             echo $element->result;           }           echo $result;           //print_r($_REQUEST);         }         die();       }       add_action( 'wp_ajax_script_handle', 'widthcalculate' ); // Hook for the WordPress Dashboard.       add_action( 'wp_ajax_script_handle_nopriv', 'widthcalculate' ); // Hook for the user facing side of the site.            function register_scripts() {         wp_register_script( 'script-handle', $path_to_javascript_file, $dependencies, 'version', $in_footer = true );         wp_enqueue_script( 'script-handle' );              wp_localize_script( 'script-handle', 'ObjectName', array( 'ajaxurl' => admin_url( '/wp-admin/admin-ajax.php' ), 'parameter' => $whatever_you_want_to_pass ) );       }            add_action( 'enqueue_scripts', 'register_scripts' );


title: What does $_GET['iphone'] do?

text: I am working on a WordPress theme whose news stories are loaded in an iPhone app as well. We need the theme to detect whether the news story is being loaded from a mobile browser (chrome, safari, etc..) or from the iPhone app so we can serve a slightly different stylesheet. Because I am mainly redesigning the existing theme, I know that the following code is responsible for completing that detection, but I can't seem to find out how/why it works:               if(isset($_GET['iphone'])) {         //do different stuff     }      Can someone explain the $_GET['iphone'] part? Thank you in advance! EDIT: Basically it looks like the app simply appends `?iphone` to the url is it requesting.


title: Multiple Frontend Filters Using Advanced Custom Fields

text:
I've got a series of custom post types set up, and a large amount of custom fields are linked to these post types via the Advanced Custom Fields plugin. I want to set up a series of checkboxes on the frontend to filter posts via their custom fields. This is what it looks like at the moment: ![enter image description here](http://i.stack.imgur.com/7HeY3.jpg) And here's the code I'm using to produce it on my **archive-books.php** page:               <?php $array = array('format', 'bedrooms', 'type'); ?>     <?php foreach ($array as $value):         $field = get_field_object($value);         $values = explode(',', $_GET[$value]);     ?>         <div id="<?php echo $value; ?>" class="filter">
<?php echo $value; ?>
             <ul class="<?php echo $value; ?>">                 <?php foreach( $field['choices'] as $choice_value => $choice_label ): ?>
                         <input type="checkbox" value="<?php echo $choice_value; ?>" <?php if( in_array($choice_value, $values) ): ?>checked="checked"<?php endif; ?> /> <?php echo $choice_label; ?>

                 <?php endforeach; ?>

     <?php endforeach; ?>      Now this works great! I define the custom fields I want to pull filters in for with that array at the top. And I'm using some Javascript to edit my URL depending on the selections made by the user (like shown in the screenshot above). Here's my JS:                     What I'm trying to work out is how to dynamically alter that Javascript. So instead of "format" it uses the custom fields from my `$array`. This also needs to take into account multiple filters, so the URL would look like this: > dev.website.com/books?format=paperback&type=home,men If anyone could help with the Javascript, I'd really appreciate it. I've tried to include it in the `foreach` loop, but no dice. Any help is appreciated! Thanks.


title: Slow wp_term_relationships query

text: I'm running a large WP instance (currently has 28,000+ posts in custom types) and have been experiencing some odd slowdowns. Upon analyzing the MySQL slow query log, one of the problem queries is:               SELECT COUNT(*) FROM wp_term_relationships, wp_posts      WHERE          wp_posts.ID = wp_term_relationships.object_id          AND post_status = 'publish'          AND post_type IN ('s5_video', 's5_post', 's5_one_liner', 's5_image')          AND term_taxonomy_id = 1498      (s5_video, s5_post, s5_one_liner, and s5_image are our custom types) Doing an explain on the query yields the following: ![enter image description here](http://i.stack.imgur.com/1BPwT.png) Now, 23,000 rows analyzed is a lot, but not terrible, especially for a query that isn't run too frequently. In fact, in my manual testing, much of the time, the query only takes 50ms or so to execute (presumably because it is still in MySQL's query cache). However, sometimes, the query takes 12-16 _seconds_ to execute. I suppose I have two questions:   1. Our mid-range VPS has plenty of power to handle this type of query (8 CPUs, 4GB RAM). The SQL EXPLAIN result shows that MySQL is, in fact, using the keys to generate the result. Given the capacity of our server, as well as the use of the keys, doesn't 12-16 seconds to analyze 24k rows seem a little extreme? (That's about 1500 rows _per second_. Yuck!) Why is this happening? Has this happened on anyone else's large WP instances?   2. Any suggestions on what to do? Normally, in a situation like this, I'd add indices to speed things up, but MySQL is already using the correct keys. And as far as I can tell, this query is built in to the Wordpress core (not part of our custom code), and is straightforward enough that I can't think of how to optimize it further... ?


title: Custom field in title

text: I'm trying to change the posts with no titles to 'custom field' + 'mystring'. So far I got this code.                       add_filter( 'the_title', 'ta_modified_post_title');             function ta_modified_post_title ($title) {             if( $title == $post->post_title and !is_page() ){             $title = $title.$_POST['user-submitted-customfield'].'mystring';             }             return $title;             }      However, the custom field does not get parsed. And it only changes the post titles in the backend (/wp-admin/edit.php says there are titles, but when I view the post it says none) What am I missing?


title: Wordpress P2 live problem

text: Everything worked perfectly in localhost. When I uploaded everything online, the ajax submission seems to not working. It's refreshing the page for comments and live updated is not working I have this which appear when i'm on my online server (console):   Uncaught TypeError: undefined is not a function For the function : locale = new wp.locale( wpLocale ), I don't have this error when I'm in localhost. Any suggestion ?


title: laoding bloginfo url in function array?

text: I'm using wp customizer in a theme and I want to load a page using a link in admin bar. Link in admin bar is added, and link format is like this: http://www.domain.com/dashboard/customize.php?url=/page_to_edit However, it still loads the homepage in the customizer iframe, so guess I'm doing something wrong. For reference, This is the code I'm using (the part that matters):               $admin_bar->add_menu( array(             'id'    => 'my_page',             'parent' => 'customize_page',             'title' => 'My Page',             'href' => admin_url( 'customize.php?url=/my_page/'),             'meta'  => array(                 'title' => __('My Page'),                 'target' => '_self',                 'class' => 'my_menu_item_class'             ),      Now, if I load the full absolute URL it works fine, but no idea how to make bloginfo load inside this array. I found in another post that I can use get_bloginfo (not sure if that's correct) but also no idea how to make it work after the admin_url part. Any help really appreciated, this is driving me crazy!


title: What is the best way to store HTML fragment in WordPress?

text: Let say I want to store an HTML fragment in WordPress and allow user to update/modify, e.g. site wise notice, what is the best way to store it and present them in a theme? e.g.   * write a plugin to add in `wp_options` table, need to create our own admin pages   * use Theme Customization API (i.e. as theme settings)   * create a new page for that purpose, and in `header.php`, load the content of that page Or other method?


title: Get parent category name and content

text:
How can I get my parent category info in my category page. Let me explain details. Say like I have a category like               Photos       Gallery One       Gallery Two       Gallery Three      I used feature category image plugins also, so my menu is photos. When I will click photos it who all parent category name and featured image Feature image shortcode is `[FeaturedImagesCat taxonomy='category' columns='3']` I think I can get feature image easily but main thing how to show parent category name with permalink               <?php          get_header(); ?>
<?php if (is_category()) { single_cat_title(); } ?>
             <?php     $category = get_the_category();     $parent = get_cat_name($category[0]->category_parent);     if (!empty($parent)) {     echo '» ' . $parent;     } else {     echo '» ' . $category[0]->cat_name;     }     ?>          <?php get_footer(); ?>


title: How to delete/hide this character after user post nothing

text: When user did post a blank comment or post it will come out the extra character which is "-1". How can I hide/delete the character? ![enter image description here](http://i.stack.imgur.com/F1co5.png)


title: custom taxonomies are not showing up in get_taxonomies

text: I've made several taxonomies through the custom post type ui manager but i am not able to call them with get_taxonomies and my get_terms is not working either. Is there something I have to do after creating a custom taxonomy in order to get it fully functional? $tax = get_taxonomies(); var_dump($tax); returns only the build-in taxonomies and none of my custom ones.


title: Share buttons Facebook Twitter, just like wordpress.com without webservice

text: I'm working on a blog which migrated from wordpress.com, which now is self- hosted. I created a theme based off their CSS customizations, and everything is working. I'm looking to add the Facebook and Twitter buttons, to the end of posts and end of posts on front page. Essentially In the same manner as wordpress.com. I have found a slew of hideous share plugins. Which seem to be either be ugly hacks, or bloated full of web services via JavaScript. I want simple Facebook and twitter share buttons; not every service on the entire net; not bloated with third party web services. The closer to the wordpress.com the better, a small 16x16 button and a text label. CSS for the image would be proper, but... not expecting miracles. If anyone knows a good plugin that can be simply hacked up, or something that looks as wordpress.com but isn't a thick web service. please help me out. NOTE: List of not acceptable plugins I've already experimented with. All of these use a JavaScript web service, most load multiple .js files some load from an outside source.   * ShareDaddy / JetPack   * ShareThis   * AddThis   * Socializer   * SharePost


title: Lots of SQL queries

text: I have a site with more than 300,000 posts (but really little posts) and cheking why is going so slow I've seen that in the hompage it makes something like this: "Generated in 15.024 seconds. Made 9492 queries to database and 0 cached queries. Memory used - 81.12MB" Home only displays the first 10 psts and runs a couple of twitter plugins, any idea about how to reduce this massive amount of queries? Thanks!


title: Empty search returns home page, how to return not found search page?

text:
The default search function if the search form is empty returns the home page, I want it to return a "sorry your search returned no results" page. this post doesn't answer it and this ticket tells me that it is supposed to function that way! Anyone figure out how to change it besides using a .htaccess redirect? I'm using the following search.php file: `

Search Results for: <?php echo esc_attr(get_search_query()); ?>
                          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                          <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>

<?php _e("Posted", "bonestheme"); ?> <time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time('F jS, Y'); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?> & <?php _e("filed under", "bonestheme"); ?> <?php the_category(', '); ?>.

                             <?php the_excerpt('Read more on "'.the_title('', '', false).'" »'); ?>

                           <?php endwhile; ?>                            <?php if (function_exists('page_navi')) { // if expirimental feature is active ?>                              <?php page_navi(); // use the page navi function ?>                          <?php } else { // if it is disabled, display regular wp prev & next links ?>

<?php next_posts_link(_e('« Older Entries', "bonestheme")) ?>

<?php previous_posts_link(_e('Newer Entries »', "bonestheme")) ?>

                                              <?php } ?>                                    <?php else : ?>

No Results Found

Sorry, but the requested resource was not found on this site.

                          <?php endif; ?>

                          <?php get_search_form(); ?>

       `