title: Placement of Code in Plugin for hooking `save_post`

text: I ran into a strange Problem today developing a new Plugin. I set it up as usual, creating the `f711-roomprice` folder in the Plugindirectory, and creating the `f711-roomprice.php` as well as an `inc` directory in there. Everything worked fine with the activation hook and the included functions, until i created an include:               include('inc/filter-savepost.php');      this file contained the following code:               add_action( 'save_post', 'f711_roomprice_meta_box_save' );       function f711_roomprice_meta_box_save( $post_id ) {              if( !isset( $_POST['f711_roomprice_prices'] ) ) return;              if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;               if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'f711_roomprice_box_nonce' ) ) return;               if( !current_user_can( 'edit_post', $post_id ) ) return;              foreach( $_POST['f711_roomprice_prices'] as $room => $seasons ) {             foreach( $seasons as $season => $price ) {                      f711_roomprice_insert( $room, $season, $price );                  }              }          }        After including the file in my main plugin file, I got an Error resulting in a white screen on Saving a post, everything else worked fine. The function `f711_roomprice_meta_box_save` is called, confirmed this with an `wp_die('f711_roomprice_meta_box_saveis called')` in there. Now the strangest thing is, i placed the code (exactly the same as in the include file) in my main Plugin file, and skipped the include of course. Now it works just as I want it to. I also tried just adding the `save_post` action in the main Plugin file and including the function from `inc/filter-savepost.php`, still got the wrong result as before. What am I doing wrong here? Is the placement of the Code (Hooks, Functions) really important in a Plugin, or is it just something on my part gone wrong?


title: Display only one level subcategory in wordpress

text:
This code uses taxonomy category image plugin to display images for categories. This code display subcategories of main category in parent category page (`category.php`), But I want to display only one level of subcategory in the page for example hardware (parent category)   * monitor (first level subcategory of harware)     * samsung (second level subcategory)       * lcd (third level subcategory ) When the user clicks on the hardware link, he should see only monitor subcategory link and in second time when he clicks on the monitor, he should see the samsung category link, and when he click on the samsung the subcategory LCD will displays. How should I change this code to do my word My code:               <?php     $cat_id = get_query_var('cat');     $catlist = get_categories('hide_empty=0&child_of=' . $cat_id);     echo "
";          foreach($catlist as $categories_item)     {     echo '
term_id ) . '" title="' . sprintf( __( "View all products in %s" ), $categories_item->name ) . '" ' . '>' . $categories_item->name.'
 ';          echo '
';         $terms = apply_filters( 'taxonomy-images-get-terms', '' );         if ( ! empty( $terms ) ) {                foreach( (array) $terms as $term ) {             if($term->term_id == $categories_item->term_id) {                print 'taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'thumbnail' );                echo '';             }         }         echo '
'. $categories_item->description; echo '
';     }     echo '
';     }     echo "
";     ?>


title: How to display different single post template based on author?

text: My current singlepost.php makes use of the following if conditions and renders the appropriate template.               <?php     $post = $wp_query->post;         if ( in_category('4') || in_category('59') ) {             include(TEMPLATEPATH . '/review-post.php');             }         elseif (in_category('5')) {             include(TEMPLATEPATH . '/promo-post.php');             }         else {             include(TEMPLATEPATH . '/regular-post.php');             }     ?>      I want to modify this such that /123-author.php single post template is rendered when a post is published by a particular author. How can I modify/append to the above conditions so that the single post would look for a particular template whenever it notices a post made by 123author? Thanks.


title: Wp e-commerce shipping problem

text: I am designing my first e commerce site with wp e-commerce. My problem is, that I installed the simple shipping plugin, ind I set on fix rate shipping. After the I go to the front end, and buy something, click on the purhchase, and i see my cart, with the details. I can see the two options i set for fix rate. But the problem is that above the shipping options there is a sentence that wouldnt be there: "Please choose a country below to calculate your shipping costs". But I set fixed rate shipping so this sign wouldnt be there. How can i delete it? Thank you very much


title: WP Codex answer incomplete? Put WP in subdirectory. .htaccess change required

text: I have installed Wordpress in a subdirectory '/medical' and want the address to show up as www.mysite.com/page not www.mysite.com/medical/page The Wordpress Codex here : https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory says to replace               require('./wp-blog-header.php');       with               require('./wordpress/wp-blog-header.php');      but that line does not appear in the generated .htaccess file. I've tried just inserting the line before the /ifmodule tag but it breaks the site... Thanks!               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /medical/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /medical/index.php [L]     </IfModule>     # END WordPress


title: What's the best action to use when you want to do something only once per theme setup?

text: I'm writing a theme which has it's own set of database tables.   I'm wondering what is the best action for me to use when I want my install function to be invoked only once when the theme is activated for the first time? I know there is a `setup_theme` action, but not sure if that's the one I should use.


title: Where in functions.php to add this code so thumbnail images display?

text: Thumbnail images are not displaying by blog excerpts on my blog at http://richardclunan.com/blog/ -- I found some code that I think I might need to add to functions.php to make this happen, and if I do need to do this, I'd like to know where in functions.php I should add the code... In my twentyeleven files, in functions.php, it says: // This theme uses Featured Images (also known as post thumbnails) for per- post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); But the following code isn't in functions.php: if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post- thumbnails' ); } If my understanding of this: http://codex.wordpress.org/Post_Thumbnails is correct, then maybe I have to add that code into functions.php to make thumbnails appear on my blog ...? Where in the file functions.php would I add the code? And I presume curly brackets } signify the end of lines of code -- so I guess I'd paste the code after a curly bracket somewhere?


title: Change Attachment Post URLs to File URLs

text: I have a client with a very image heavy blog. Every time they upload images in their posts they are using the Attachment Post URL for the link instead of the File URL. The problem with this is that there is an image plugin that automatically zooms images nicely if they are links to the file but won't work if it's a link to the attachment page. Is there any way to force all links to attachment URLs to point to the File URL instead? I tried redirecting my attachment.php but that won't change the link in the index.php or single.php. Thanks for your help. I can't go through and change every existing post or prevent the client from doing this in the future.


title: Cloning blog to localhost via WAMP

text: How do restore a Wordpress blog (actually, cloning would be the right word) from my server to localhost with WAMP? I backed up my blog with BackUpWordPress and got a `.zip` file `sitename.backup.2012-01-29-12-50-08`. As per instructions, I unzipped the file and got a complete Wordpress installation (folders `wp-admin`, `wp- content`, a bunch of files, `.htaccess` etc.) and an SQL database named `database_myusername_wrdp2`. I copied all the files except the database to WAMP's `www` folder. Then I opened phpMyAdmin through WAMP, created a database named `wordpress`, opened that database and used Import button to import `database_myusername_wrdp2` to this new database. Unfortunately, there is obviously no connection between the installation and a database as I get `Error establishing a database connection` message when I try to open `localhost`. What am I doing wrong? How do I clone this blog locally?


title: Grab the Post ID created by wp_insert_post($post)

text: Okay apparently there have been at least a few people already asked this question (1, 2), but none seems to get the right answer... wp_insert_post() and the following update_post_meta() & wp_insert_post(), both never work without Post Id, but never let me pass the id from php function to ajax success. Here is my code:               function save_post_aha() {     global $wpdb;     $title = $_POST['t'];     $t = strip_tags($title);          // some codes to grab other data          // post it up!     $post = array(     'post_title' => $t,     'post_content'  => $c,     'post_status'   => 'pending',     );          $postid = wp_insert_post($post, true);          update_post_meta($postid, 'summary', $d);     set_post_format($postid, 'quote');          die($postid);      This returns nothing (blank) as previous commentators stated. But below works flawlessly, which means there's something wrong going on when passing Post Id by using die($postid).               function save_post_aha() {     global $wpdb;     $title = $_POST['t'];          // some codes          die($t)      UPDATE: Turned out this is because Die() doesn't print Intereger! Reference > If status is a string, this function prints the status just before exiting. > > If status is an integer, that value will be used as the exit status and not > printed. Exit statuses should be in the range 0 to 254, the exit status 255 > is reserved by PHP and shall not be used. The status 0 is used to terminate > the program successfully. This can be fixed by adding this code before Die():               $id = strval($id);      # Heading


title: Will multiple BuddyPress groups slow down a site?

text: I'm looking into creating a support forum where each product has it's own mini support forum. I was told that BuddyPress could work well for this, but I'm wondering how that scales for a site that has hundreds or thousands of active products. Any idea what kind of impact that would have on site speed and performance? **Edit:** To make the reason for this more clear, the site is a marketplace, where each product can have a different seller. That's why I'm not looking (nor do I care for) a central support system. Each individual seller is responsible for their own support.


title: How to display users with posts published between two dates (Sorted by Post-Count) [Multisite]

text:
I'm trying to make a list of users who have published posts within two given dates. My attempts using WP_User_query just work for one blog ID and takes time to load because it runs through a lot of `foreach` and `if` statements. Also it seems that not all users are stored in the arrays I'm using. I have a feeling that I'm doing it totally wrong but I can't find any wordpress function which could help me. I would like to do this with an wpdb query but I don`t know how to check for all users and their post count. My current code is this:               $blogids = array( 2, 4, 5, 6 );          global $blog_id;          $startdate = "2012-03-01";     $enddate = "2012-04-31";          //$wp_user_search = new WP_User_Query( array( 'role' => 'subscriber', 'blog_id' => $blog_id, 'fields' => array('ID', 'user_nicename', 'display_name') ) );          $userlist = array();     $usercountlist = array();          foreach($blogids as $blogid) {              $wp_user_search = new WP_User_Query( array( 'role' => 'subscriber', 'blog_id' => $blogid, 'fields' => array('ID', 'user_nicename', 'display_name') ) );         $usernicenames = $wp_user_search->get_results();          foreach($usernicenames as $usernicename){                   $user_count = $wpdb->get_var( $wpdb->prepare( "         SELECT COUNT(ID) FROM ". $wpdb->base_prefix . $blogid ."_posts WHERE post_status = 'publish' AND post_type = 'post'         AND post_author = ".$usernicename->ID." AND post_date >= '".$startdate."'         AND post_date < '".$enddate."' HAVING COUNT(ID) > 0         " ) );                   //$userlist[$user_count] = $usernicename->user_nicename;              if($user_count) :           $userlist[] = $usernicename->display_name;           $usercountlist[] = $user_count;         endif;              }          }               $userlist = array_combine($userlist, $usercountlist);          $str = serialize($userlist); // Serialises the array $array and store as $str     $strenc = urlencode($str);  // Encode the serialised array          $temp_folder = str_replace("//", "/", $_SERVER['DOCUMENT_ROOT']."/_temp/");          $file = $temp_folder.'userstats.txt';     file_put_contents($file, $strenc);          $content2 = file_get_contents($file);     $arr = unserialize(urldecode($content2));          echo "
";     arsort($arr);     $i = 0;     foreach ( $arr as $key => $value ) {     if($value > 0 && $i < 10):     echo "
".$key." (".$value.")
";     $i++;     endif ;     }     echo "
";


title: How do I list a custom field and custom taxonomies for each result in a loop?

text: How do I list a custom field and custom taxonomies for each result in my loop below?               <?php     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query();     $wp_query->query('post_type=customtype&showposts=10'.'&paged='.$paged);     while ($wp_query->have_posts()) : $wp_query->the_post();          the_title(); // <- works     //list custom field here     //list custom taxonomy here          endwhile;          wp_pagenavi();                   ?>


title: Use Custom Database with Custom Post Type

text: I decided to ask this question as searching online left me really overwhelmed and not knowing which direction to take. I am about to tackle a project that has its own custom database (finished e-r design) in MySQL, and I want to use Wordpress as its CMS.   1. Can I make custom post types but pull/save records from/to the custom database? if so, any link to resources would be much appreciated, like:     * Should I merge the databases or can I keep working them independently?     * For the custom post type's admin area, how do I use this to pull/save entries from/to the custom database's table(s) for individual records?     * Do I use/make custom fields in the custom post types and then rely on some hook to pull/save them from/to the custom database?     * Will I be able to delete the posts in Wordpress and also delete the corresponding entry in the custom database?   2. Is there a wiser way to go about this whole thing? I'm very open to suggestions/informed guidance. I found the following resources, but I just can't pull them all together:   1. http://stackoverflow.com/questions/7538337/save-the-data-of-custom-metabox-to-database - but how do I do this for a custom database?   2. http://www.deluxeblogtips.com/meta-box - is this something I should look at or is it overkill?   3. http://Wordpress.org/support/topic/migrate-from-custom-database-to-Wordpress-database - this kind of hits the spot but not quite; if I want to work on the custom database without merging it with Wordpress what do I do? Again, I'm just fumbling my way around these options as these are what I've come across so far. If someone knows a better/more correct way to tackle the whole problem and not just piecing-together disparate info ending up with a frankensteined setup then I would love to hear what you have in mind.


title: Paypal Post IPN handeling nightmare

text: I'm trying to integrate paypal standard with my Wordpress site and all was going well until I wanted to do one simple thing:   * The user submits a paypal payment   * Paypal posts the IPN to my server   * Post IPN Hook adds a user_meta   * If user reloads current page, it checks to see if previous user_meta is set to 1, if it is, displays "you have already purchased your ticket" I thought this would be pretty straight forward, but if I add this to my `functions.php` for the post IPN Hook :               add_filter("gform_paypal_post_ipn", "update_order_status", 10, 4);     function update_order_status($ipn_post, $entry, $config, $cancel){              // if the IPN was canceled, don't process         if($cancel)             return;              global $current_user;         get_currentuserinfo();         $currUID = $current_user->ID;         update_user_meta($currUID, 'eventRegistration', 1);              return;      }      Absolutely nothing happens. My thought is that since the IPN is bouncing from off-site, maybe the user ID isn't available? Or am I wrong here? Figuring that I'm correct about the user ID not being avail, I was thinking of another way to grab the user ID. Since I'm using Gravity Forms with the PayPal addon, all forms submitted are stored in a database tables `wp_rg_lead` & `wp_rg_paypal_transaction`. Since every IPN posts a transaction id, I figured I could do a JOIN between the two tables using the transaction ID sent by paypal. so I tried:               $txn_id = 'aRandomStringOfNumbersAndLetters'; // The transaction ID that paypal POSTs          $uid = $wpdb->get_col( $wpdb->prepare(      "     SELECT wp_rg_lead.created_by     FROM wp_rg_lead, wp_rg_paypal_transaction     WHERE wp_rg_lead.id = wp_rg_paypal_transaction.entry_id AND wp_rg_paypal_transaction.transaction_id = %s     ",     $txn_id       ) ); which returned the user ID associated with the transaction ID. I thought to myself, great! This will work! However, if I try to combine all this in to my `functions.php` nothing seems to work in its entirety. This:               add_filter("gform_paypal_post_ipn", "update_order_status", 10, 4);     function update_order_status($ipn_post, $entry, $config, $cancel){              // if the IPN was canceled, don't process         if($cancel)             return;              $txn_id = $ipn_post["txn_id"]; // transaction ID POSTed by PayPal              $uid = $wpdb->get_col( $wpdb->prepare(          "         SELECT wp_rg_lead.created_by         FROM wp_rg_lead, wp_rg_paypal_transaction         WHERE wp_rg_lead.id = wp_rg_paypal_transaction.entry_id AND wp_rg_paypal_transaction.transaction_id = %s         ",         $txn_id          ) );               update_user_meta($uid[0], 'eventRegistration', 1)                   return;      }          function update_order_status($ipn_post, $entry, $config, $cancel){              $txn_id = $ipn_post["txn_id"]; // transaction ID POSTed by PayPal              $uid = $wpdb->get_col( $wpdb->prepare(          "         SELECT wp_rg_lead.created_by         FROM wp_rg_lead, wp_rg_paypal_transaction         WHERE wp_rg_lead.id = wp_rg_paypal_transaction.entry_id AND wp_rg_paypal_transaction.transaction_id = %s         ",         $txn_id          ) );               update_user_meta($uid[0], 'eventRegistration', 1)     }      Produced nothing useful. If I remove the SQL query and say change the update_user_meta to `1, 'eventRegistration', $txn_id` and submit a paypal request, the meta updates fine. I'm kind of at a loss, I must be missing something. Any help would be much appreciated! Thanks! Tre


title: GD star rating function problem

text: If anyone can help me out with this you'll be a life saver. I've been trying to use the wp_gdsr_render_review() function to add the results to my theme with no success. The results appear fine if I use the GD star rating widget so they are definitely being stored okay. Is there a known problem with wp_gdsr_render_review()? I created the function using the build tool. Here is the exact code I used: wp_gdsr_render_review(get_the_id(), 54, 'oxygen', 16); Please help! Martyn


title: Custom metabox for menu administration page?

text: I've been googleing around but failed to find a solution for my need. I'm using wordpress 3.0 and TwentyEleven theme as default pack. In the Dashboard -> appearance->menus that allow user can create menu items from Pages,Categories,and custom link. Now I want to add a box like those boxes above but it would list my custom-post-type's taxonomy and metadata. How can I accomplish with this task ? I know how to add metabox and taxonomy for custom post type but cannot do with this sort of thing.


title: Custom ul class

text:
I need help for my custom Wordpress Layout. It should look like this (HTML):

                  About

                  Services

                  Contact

      In Wordpress:

Test/Site

      My Code:               <?php         wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'collapse navbar-collapse navbar-ex1-collapse' ) );      ?>


title: How to create a custom shortcode based on the layout?

text: Hi I am developing a custom post type plugins. Which has shortcode support. Already i have created a shortcode which is going to use for default layout design. Again i have to create a onemore shortcode for another layout design. My current shortcode **[testimonial]** i want the shortcode something like this **[testimonial style="fancy"]**. How can i do it.can any one suggest me . Thanks


I made a local clone of a website that's running LIVE in order to safely work offline for a while. On every page of the local version I get a HUGE warning which says **Notice: Constant WP_POST_REVISIONS already defined in C:\xampp\htdocs\local- tutorials\wp-config.php on line 95** I guess it's been defined twice, once in `wp-config.php` and once elsewhere, right? However, I've no clue where it's been defined for the second time. I searched `wp-config.php` for a second instance but no luck. I then checked the `functions.php` in my theme but it doesn't contain any statement on revisions. Googling leads mainly to rather old threads that seem to address a different issue. I believe the error is related to a reasonably recent (< 1 year?) Wordpress update since it didn't occur previously but I'm not 100% sure on that. Thank you in advance for any suggestions. **UPDATE** After searching all files, three contained `wp_post_revisions`:   * C:\xampp\htdocs\local-tutorials\wp-config.php    * C:\xampp\htdocs\local-tutorials\wp-includes\default-constants.php    * C:\xampp\htdocs\local-tutorials\wp-includes\revision.php I commented out the `wp_post_revisions` in `default-constants.php` and this seems to solve the problem. I find that a bit awkward since `wp-config.php` is (partly) meant to override default constants. So I think it's strange I get this huge error when I do so. Or am I missing something?


title: Is it possible to remove subscription box from Jetpack stats page?

text: Is it possible to remove following box from Jetpack's stats page as I'm using Feedburner? ![Jetpack](http://i.stack.imgur.com/X1tiV.png)


title: save_post not working

text: In order to create (or update, whenever a post is updated) a unix-timestamp meta, I used following code to fire on save_post. I pasted this code in functions.php. But I believe this is not working, as I can't access the related unix meta created by save_post in loop anywhere in a custom template. **EDIT:** After answers and comments I added priority and arguments in save_post hook event and also updated the way of retrieval. The problem now seems as follows - When a post is created then the save_post does not fires, but if I update the post (after creating it) save-post fires. Plus, on updation (at any point after creation) if I change values of start date and end date, it doesn't reflect, it always takes the value which was used while creating the post. Code -               function vg_update_timestamp( $post_id, $post ) {              $offerstartdate = get_post_meta($post_id, 'offer_cmb_offer_from_textdate', true); //not unix timestamp         $offerenddate =  get_post_meta($post_id, 'offer_cmb_offer_till_textdate', true);  //not unix timestamp              $timestamp_start = strtotime( $offerstartdate );         $timestamp_end = strtotime( $offerenddate );              update_post_meta($post_id, 'offer_cmb_offer_from_textdate_unix', $timestamp_start );             update_post_meta($post_id, 'offer_cmb_offer_till_textdate_unix', $timestamp_end );       }     add_action( 'save_post', 'vg_update_timestamp', 0, 2 );      In Template (Custom Template) am using following code to retrieve the field -               $unix_version_s = get_post_meta($post->ID, 'offer_cmb_offer_from_textdate_unix', true);     $unix_version_e = get_post_meta($post->ID, 'offer_cmb_offer_till_textdate_unix', true);          $unix_start = strtotime($unix_version_s);     $unix_end = strtotime($unix_version_e);          /******     Converting date to desired format      **************************************/          $offerstartdate = gmdate("l, M j, Y", $unix_start);     $offerenddate = gmdate("l, M j, Y", $unix_end);          /*****     and then am using $offerstartdate and $offerenddate wherever needed, but its returning Jan 1, 1970 [which i think is because the value is zero or nill]     *****/


title: 404 error on cyrillic url

text: I am using Another Wordpress Classifieds Plugin (awpcp) with Ukrainian translation. Due to it's limitations I am forced to use Cyrillic urls. While the site navigation works perfectly, when I reload some pages or create an external link to those pages I receive a 404 error. Normalize URLs 1.1 Plugin fixes problem completely, but for some reason my homepage stops loading.. Site is hosted on Hostgator shared hosting with php 5.3 enabled. Wordpress version is WordPress Uk 3.4.3-alpha. To access problematic page please click "Куплю (0)" category on the following page: ukrcoins.com/дошка-оголошень/ Please, advice a possible solution. Thanks! Getting a Normalize URLs 1.1 Plugin to work seems to be the easiest way.


title: Wordpress widget/sidebar dividers?

text: I have a widget sidebar, but I'd like dividers between them. I can achieve this in CSS using boring borders, but I have a png image I'd rather use instead. Is there a way to insert a divider after each widget item? (apart from the last one of course). I can do this in jQuery quite easily but I'd rather do it in the template file if at all possible I'm guessing it's something for the functions file or where I register the sidebar? Thank you


title: Cookie Details Requested

text: We have Wordpress 3.4 installed and looking for details regarding functionalities of cookies created by wordpress. This information is needed so that we can align with EU cookie laws. So please suggest where can I find details.


title: Display number of posts via adress bar?

text: when i call this link ;               ?s=key&order=ASC      wp display my search query order by ASC.               ?s=key&order=ASC&number=10      how can we display whatever i want to display postnumber like 10 or more ? is that possible ?


title: Count post that have specific meta value

text: How do I count only the post that have a specific custom meta field value?               $productCount = wp_count_posts('product');     echo $productCount->publish;      That gives me all the total of all the post. How do I find out how many of those post have say a custom meta value of "cat"?


title: Feed Code Error

text: Since last Thursday I've been having this issue with my RSS feed at www.theqnews.ca/feed/ A CDATA section was not closed. Line: 34 Character: 25 Is there a fix for this? I've looked on Wordpress.org and have tried a few things there with nothing helping out. I've also posted in the Support Forums but nobody has answered. Any ideas? Thanks!


title: Format Date for Manual Insertion into post

text: I have the following `$mydate = "26 January, 2012, 5:05 AM";` I want to format this date properly so I can insert it into a post_date. Is there a simple way to do it?               $post_ information = array (         //other data is also inserted         'post_date' => $mydate;     );


title: category title and description in multi language issue

text: ![enter image description here](http://i.stack.imgur.com/NFhIK.jpg) How to change the category title and description in multi language? Plz help me anyone.. I have installed this plugin : mLanguage Version 1.6.1! 1


title: Twenty Twelve Widget Taking Space

text: I am using the twenty twelve theme and in this theme I used the `Main Sidebar` for widgets. I used the code below to make the widgets disappear in my `homepage ( front page )`. The code works however, the widget area is still taking the space. How can I stretch my content to fill the whole width?               <?php If ( !is_front_page ) { get_sidebar() } ?>      Before Applying the code the widget is still visible see image below: ![The Image Before the code](http://i.stack.imgur.com/ODUaE.jpg) After Applying The Code Above it removes the widget but the widget is still taking up space. ![After Applying the Code](http://i.stack.imgur.com/QSEID.jpg)


title: Why is the Page Title missing on Pages added with add_submenu_page?

text: Adding sub menus is easy with `add_submenu_page` and is working fine as long if you define a `$parent_slug`:               add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );      if you set the `$parent_slug` to `NULL` as described here to hide it from any menu item the title of the page will get ignored (`$page_title`)               add_submenu_page( NULL, $page_title, $menu_title, $capability, $menu_slug, $function );      I've tested it with all versions from 3.3 up to the latest 4.0


title: High CPU load when loading images in media library

text: I notice it uses high cpu when I load images from my media library. I have about over 1 million images uploaded and they are organized into folders by Post ID. Any tips to reducing CPU?


title: How to prevent deleting a user

text: I'm trying to disable the user when the user is deleted. So I want to keep the data of user, but preventing access. I know that I've the option to reassign in wp_delete_user() but I prefer keep the ID and user data. I've tried to do with this code:               remove_action( 'delete_user', 'wp_delete_user' );     add_action( 'delete_user', 'edit_user_status' );          function edit_user_status( $user_id ){         #edit user_status     }


title: Meta box dropdown of custom posts

text: I am trying to display a dropdown select metabox on the "add new" page of a custom post type which displays a drop down list of titles from a separate custom post type ( it's an effort to relate the two CPT's together - one being "clients" and the other being "projects" so that when creating a new project one would be required to select a client from the drop down select ). All works well except for the fact that somehow the query is affecting WordPress because when i click "add new **project** " instead of an empty field for the title like you'd normally get it is populated instead with the title of the first **CLIENT**. I thought that by adding wp_reset_postdata() that it would solve the problem but it didn't. Can anyone help? ( I am only adding what i think is the relevant/problematic piece of code as the metabox code itself works as expected as far as i can see and i assume the problem is with the way i've done the query)                 <select name="my_meta_box_select" id="my_meta_box_select">       <?php        $my_loop = new WP_Query( array( 'post_type' => 'clients', 'posts_per_page' => 10 ) );       while ( $my_loop->have_posts() ) : $my_loop->the_post();       $title = get_the_title();       ?>       <option value="<?php echo $title ?>" <?php selected( $selected, $title ); ?>><?php echo $title ?></option>       <?php       endwhile;       ?>                   </select>            <?php       wp_reset_postdata();       }


title: Conditional display faults

text:
I'm trying to get the line of codes below to display it's content on "web- design-portfolio" and "web-design-portfolio-2" but it ends up messing up every other pages on my website and displays the "Ul" element on them. Any ideas what the problem could be.               <?php           is_page(array('web-design-portfolio','web-design-portfolio'));  { ?>
                          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>">
                                <?php if( has_post_thumbnail() ) { ?>
  <?php the_post_thumbnail($size, $attr); ?>
<?php } ?>                                <?php the_content(); ?>                      <?php endwhile; else: ?>
Woops...

Sorry, no posts we're found.
                      <?php endif; ?>

«

1

2

»

                  <?php } ?>


title: Add a custom function to widget code

text: Hopefully, this is an easy question - I'm just a bit confused. I've got a custom widget with the usual structure:               class My_Widget extends WP_Widget {       function My_Widget() {         // widget actual processes       }       function form($instance) {         // outputs the options form on admin       }       function update($new_instance, $old_instance) {         // processes widget options to be saved       }       function widget($args, $instance) {         // outputs the content of the widget       }     }     register_widget('My_Widget');      I's like to add my own custom function to it, so I can reuse it. Something like:               function item_width_cols_to_class( $cols_num = null ) {         if( $cols_num ){             switch ( $cols_num ){                 case '2':                     return "col140";                     break;                 case '3':                     return "col220";                     break;                       case '4':                     return "col300";                     break;                       case '5':                     return "col380";                     break;                 case '6':                     return "col480";                     break;                       case '7':                     return "col540";                     break;                       default:                     return "";                     break;             }         }     }      However, when I add that code to My_Widget class I got an error saying: `"Fatal error: Call to undefined function 'item_width_cols_to_class()'"`. I'd think it's possible to add custom functions to a widget as it extends the WP_widget class. Am I doing something wrong? :S Thanks for help, Dasha


title: Edit page shown after login in Wordpress?

text: I am currently using the wp_login hook to run a php function when a user logins. However, I want to show users who login notifications (a pop up with recent posts, etc) and I was planning to do this by running a javascript function. Is it possible to edit the page shown to the user after login? This is the code I have so far:               add_action( 'wp_login', 'my_login_function' );     add_action( 'wp_footer', 'the_footer_function' );          function the_footer_function(){         if (defined('FIRST_RUN')){             echo "<script>jQuery(document).ready( function(){alert('hello');});</script>";             define('FIRST_RUN', false);         }     }          function my_login_function($user_login){          global $altdb;          $user_info = get_userdatabylogin($user_login);          $wonAwards = $altdb->get_var("SELECT achievement_id FROM user_".$user_info->ID." WHERE isTold='false'");          define('FIRST_RUN', true);          //$altdb->query("UPDATE user_".$user_info->ID." SET isTold='true' WHERE isTold = false") or die(mysql_error());     }      Any help is appreciated.


title: is_archive() doesn't work on public query var archive pages?

text: > Public query vars are those available and usable via a direct URL query. E.g.               example.net/?category_name=tech&tag=gadgets      But doesn't `example.net/?category_name=tech&tag=gadgets` show an **archive**? It definitely uses the `archive.php` template, but for some reason, the `is_archive();` conditional tag doesn't seem to work. If `is_archive();` isn't the conditional tag to check these archives with, what is?


title: Why wp_nav_menu() doesnt show the proper meny when invoked two consecutive times?

text:
I just noticed something weird I never saw before. I'm working on a project using WP 3.6.1. This project that has two different menus (actually, three, but that's not important). I'm calling them through the `wp_nav_menu` function. I've done this kind of thing quite a few times now... but today is different. Today it doesn't work :( My PHP code, placed in header.php, looks like this:
                     <?php wp_nav_menu('header_main'); ?>

                     <?php wp_nav_menu('header_secondary'); ?>
                   The menu items are declared in `functions.php` and two different Menus are configured through the dashboard to show up in each location.                   if (function_exists('register_nav_menus')){             register_nav_menu('header_main', 'Menú principal' );             register_nav_menu('header_secondary', 'Menú secundario' );         }      But the first menu keeps on being printed in the two locations. As I said above, using two different menu is something that Ive done in the past, but today I don't see the error... and there _is_ and error, as it is not working :S Any ideas?


title: Replacing parent theme's IE-specific CSS

text: I'm trying to do exactly what was apparently achieved in this discussion. However, I'm finding that my IE-specific stylesheet's being loaded all the time! My parent theme includes this in its functions.php:               wp_enqueue_style( 'twentytwelve-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentytwelve-style' ), '20121010' );      And I'm adding this to my child theme's functions.php - which, if I understand correctly, should remove the parent version of ie.css and replace it with mine:               function PREFIX_remove_scripts() {     wp_dequeue_style( 'twentytwelve-ie' );          // Now register your styles and scripts here     wp_enqueue_style( 'treetop-ie', get_stylesheet_directory_uri() . '/css/ie.css',     array( 'twentytwelve-style' ), '20121010' );          }          add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 200 );      Well, my ie.css is loading, all right, but in _all_ browsers. What did i get wrong? Thanks... adam


title: Operations with custom fields values in a loop

text:
I have a foreach for displaying all the post in one taxonomy filter by terms.   I have a custom field for display a numeric value.   What I need, is to make two math operation with all the values of that field, across all post in that term. I mean: Taxonomy X has 4 terms.   Each term has 4 posts.   Each post, has 1 custom_field.   I need to make the sum of all custom_field value in that term, and the average of that custom field. So, for now I have:               <?php foreach ( $prod_terms as $prod_term ) {     $prod_query = new WP_Query( array(      'post_type' => 'prod_cientifica',      'prod_area' => $post_slug,      'tax_query' => array(         array(         'taxonomy' => 'prod_tipo',         'terms' => array( $prod_term->slug ),         'operator' => 'IN',         'get' => 'all',          'field' => 'slug'         )     )     ) );          if ( $prod_query->have_posts() ) : while ( $prod_query->have_posts() ) : $prod_query->the_post(); ?>

<?php the_title(); ?>

<?php the_field('prod_autores'); ?>

<?php the_field('prod_info'); ?>

<?php the_field('prod_fi'); ?>

     <?php endwhile; endif; ?>      What i need, is to make the sum of all **prod_fi** field in every term. Also, the average of that field too. Any idea? Thanks! -- Edit with code. I tried several options by now. The closer one was this:               <?php     if ( $prod_query->have_posts() ) : while ( $prod_query->have_posts() ) : $prod_query->the_post();      $total_fi = array();     $meta_key = 'prod_fi';//set this to your custom field meta key     $total_fi = $wpdb->get_col($wpdb->prepare         ("SELECT meta_value FROM wp_postmeta as pm         INNER JOIN wp_term_relationships as tr ON (pm.post_id = tr.object_id)          INNER JOIN wp_term_taxonomy as tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)         WHERE 1         AND tt.taxonomy = 'prod_tipo'         AND pm.meta_key = %s",          $meta_key));         echo 'Total FI '.array_sum( $total_fi );         ?>      But, this one shows me the total ammount of all custom_field in taxonomy. this one, doesn't stop of sum in each term, it continues.               $factorI = get_field('prod_fi');      if($factorI) {$factor_total += $factorI;}     echo $factor_total;      Thank u. * * * I've found a dirty fix to this. I know this is not the way, please if someone knows the right way to do this, I will be happy!!!!               <?php     //start the foreach for each term in taxonomy     foreach ( $prod_terms as $prod_term ) {     $prod_query = new WP_Query( array(         'post_type' => 'prod_cientifica',         'prod_area' => $post_slug,         'tax_query' => array(              array(                 'taxonomy' => 'prod_tipo',                 'terms' => array( $prod_term->slug ),                 'operator' => 'IN',                 'get' => 'all',                  'field' => 'slug'                 )              )     ) );     ?>

<?php echo $prod_term->name; ?>
         <?php                   // First while for fetch the value of "prod_fi" and make the math.                  while ( $prod_query->have_posts() ) : $prod_query->the_post();              $factorI = get_field('prod_fi');              if($factorI) {$factor_total += $factorI;}                         // count post for average math operation             $count_posts = $prod_query->current_post + 1;             $factorP = $factor_total / $count_posts;         endwhile; ?>
<?php _e('Publicados: ', 'twentytwelve'); ?> <?php echo $count_posts; ?>

<?php _e('FI medio: ', 'twentytwelve'); ?> <?php echo $factorP; ?>

<?php _e('FI: ', 'twentytwelve'); ?> <?php echo $factor_total; ?>
              <?php                  //original query to fetch the post in the term         if ( $prod_query->have_posts() ) : while ( $prod_query->have_posts() ) : $prod_query->the_post(); ?>

<?php the_title(); ?>

<?php the_field('prod_autores'); ?>

<?php the_field('prod_info'); ?>

          <?php endwhile; endif; ?>
     <?php     // Reset math operation of factor_total, so it don't continue sum        $factor_total = null;        $prod_query = null;        wp_reset_postdata();      } //endforeach     ?>      * * * Edited again!               <?php      // Fetch all post in taxonomy divided by terms.      foreach ( $prod_terms as $prod_term ) {         $prod_query = new WP_Query( array(         'post_type' => 'prod_cientifica',         'prod_area' => $post_slug,         'tax_query' => array(             array(             'taxonomy' => 'prod_tipo',             'terms' => array( $prod_term->slug ),             'operator' => 'IN',             'get' => 'all',              'field' => 'slug'             )         )     ) );     ?>     <?php if($prod_query->have_posts()) : ?>

<?php echo $prod_term->name; ?>
         <?php          // Declare total and count before loop         $factorTotal = 0;         $factorCount = 0;         // First loop to fetch prod_fi value         while ( $prod_query->have_posts() ) : $prod_query->the_post();                      $factorI = get_field('prod_fi');              if($factorI) { // Only if it exists                       $factorTotal += $factorI; // Add it                       $factorCount++; // Count it             }         endwhile; ?>
            <?php _e('Publicados: ', 'twentytwelve'); ?> <?php echo $factorCount; ?>

            <?php _e('FI medio: ', 'twentytwelve'); ?> <?php echo $factorTotal; ?>

            <?php _e('FI: ', 'twentytwelve'); ?> <?php echo ($factorTotal / $factorCount); ?>
              <?php         if ( $prod_query->have_posts() ) : while ( $prod_query->have_posts() ) : $prod_query->the_post(); ?>

<?php the_title(); ?>

<?php the_field('prod_autores'); ?>

<?php the_field('prod_info'); ?>

         <?php endwhile; endif; ?>
     <?php endif; ?>     <?php     // Reset things, for good measure     $factor_total = null;     $prod_query = null;     wp_reset_postdata();     } //enforeach     ?>


title: get_post_meta() not loaded with wp-load

text: I am executing this code in my external php file (= I am accessing his externaly without loading the full WP; I have a reason why I am doing it) that is located here:               http://******.com/wp-content/themes/mycartheme/file.php      I have this code to check if the code exist in the post_meta table and if yes grab the post_id of that row and make another query to grab the custom field value `rw_email_dealer` of that post id.               define( 'SHORTINIT', true );     require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );          global $wpdb;          $code = "2302327676";          $unique_check = $wpdb->get_var(                   "SELECT post_id                    FROM {$wpdb->postmeta}                    WHERE meta_key = 'rw_code'                    AND meta_value = '{$code}'                    LIMIT 1"     );          if ($unique_check == NULL) {        die('Die!');     }     else {         $email_dealer = get_post_meta($unique_check, 'rw_email_dealer', true);           print_r($email_dealer);     }      I can get the $unique_check (the post_id value). No problem here. However, if I try this               $email_dealer = get_post_meta($unique_check, 'rw_email_dealer', true);       I am getting the error:               Fatal error: Call to undefined function get_post_meta()       So, I guess that the code for that function is not loaded with:               require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );      How can I solve that so I can use that function `get_post_meta()` in external php files that don't come with WordPress?


title: Cannot seem to replace the native menu with the menu I created, so 2 menus appear

text:
Helping a friend w/ a navigational menu on a WordPress PHP site -- called it **Primary Menu**. I'm trying to override the default navigational menu with the jquery-mega-menu I created in the widget area I created. **Here's the problem:** I'd like to have the menu in the widget area I created, " **my_mega_menu** ", which calls the Primary Menu. But the inkthemes_nav() function adds the Primary Menu also. When I comment this out in header.php, it shows only the menu I want it to show, but it breaks the functionality of the menu; the drop- downs don't drop down into the sub-menus. Does anybody know if it's possible to eliminate the inkthemes_nav native menu, but maintain the functionality of the jquery-mega-menu I created? ![Double Menu](http://i.stack.imgur.com/W5pbQ.jpg) **Here's the code in my header.php:**

                       <?php _e('Pages Navigation Menu', 'colorway');      ?>              <?php inkthemes_nav(); ?>                 <?php /* Widgetized sidebar */     if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('my_mega_menu') ) : ?>     <?php endif; ?>

      Thanks for any guidance anybody can offer to point me in the proper direction (what I should be looking for, what to do, etc.)!


title: Redirect after get_delete_post_link

text: I've created a custom post type with front-end submission. I added a delete link using `get_delete_post_link` ... which works great, except it brings me to a "Page not found" after the post is deleted. I'd like to be able to redirect to another page after the post is deleted. I know I can use the `add_filter( 'get_delete_post_link', 'some_function' )` ... but I wouldn't want that to fire every time that function is run in case I create other custom post types with front end submisison. I know about `wp_delete_post`... but I can't call that from a link. What would be the best way to do this? Can't find any real solutions after some reading. Thanks!


title: WordPress Multisite Dilemma!

text: We are running our main domain as a WordPress install from past 3 years and were adding sub-domains as seperate WordPress installs. With the time, we thought that it would be a better idea to have our main domain as a MultiSite and manage other sub-domains as its child sites. But the question is - Is it worth? What would happen to the links? What about the SEO that have build up in three years? Is there anything to worry about? If anyone of you can answer this and also - What needs to be done to move an already running site to a MultiSite interface? Thanks a ton, in advance.


title: Custom priority with the_content filter based on user input

text: Currently, in my plugin Contextual Related Posts, I have an option to automatically add the related posts to the content using               add_filter('the_content,'ald_crp')      I know I can change the priority of the filter by adding a number greater than 10 (which is WordPress default).               add_filter('the_content,'ald_crp',20)      However, what I would like to do is let the user set the priority of the filter from within the options page which I can use and set the_content filter accordingly. The plugin already has its own settings page. My plugins doesn't use classes. It uses functions. Any suggestions / code samples for this?


title: get meta fields and taxonomy of any post type

text: I have created 6 different custom post type, each having different post meta and taxonomies associated with it. I am displaying all different custom post types in a dropdown using `get_post_types()` function, Now, onchange of dropdown, I want to display associated meta fields and taxonomy. I know that this information is not saved in DB unless a post is created, so is it possible to read this information like WordPress is reading or please suggest me if this is possible or not.


title: How to use Repeater field of advance custom field

text:
I have crated one Repeater field with four sub field, how to write code in the place of my html for exp ,this a HTML code

Fencing

Slashing

Earthwork

Excavation

Equipment


title: echo category description in single.php

text: i asked this on SO but got no where. i will try asking here. this works fine in category.php `<?php echo category_description(the_category_id()); ?>` but it does not work in single.php, just the category id shows up not the description. any ideas, how to get this done? thanks in advance Edit: in category: `<?php echo strip_tags(category_description(4)); ?>` in single `<?php echo category_description(the_category_id()); ?>` cat id = 4 i know i'm not striping the tags..for single i'm just trying to display the cat desc when in the single post page.


title: Pull in taxonomy links using get_the_terms?

text:
I am having issues with the get_the_terms php that is pulling in my current posts categories (custom taxonomy portfolio_category). I can successfully pull in the last category. If you look at this page you'll see links along the top: http://www.slarc.com/portfolio-view/central-control-building-east-texas/ those links are pulled in via get_the_ters_list but the links don't have: www. slarc. com / projects in front of it. Where I need it to jump to a page with the same slug. That's why I started working with the code below. It works, but it only pulls in ONE taxonomy? This is the second line of links on the page: http://www.slarc.com/portfolio-view/central-control-building-east-texas/ PHP Code: ID, 'portfolio_category' );                               if ( $terms && ! is_wp_error( $terms ) ) :                       $portfolio = array();                      foreach ( $terms as $term ) {                     $portfolio[] = $term->name;                 }                      $portfolio_category = join( " | ", $portfolio );             ?>

                     <?php echo 'slug.'">'.$term->name.''; ?>

                  <?php endif; ?>      How can I pull in all the taxonomies?? FYI-Ignore the links on top that show up. These are brough in with the get_the_terms_list But those need the http:// www. slarc.com/ projects in front of the links. Thanks, Lorne EDIT (GOT THE WORKING CODE Thanks jfacemyer!): PHP Code: ID, 'portfolio_category' );                               if ( $terms && ! is_wp_error( $terms ) ) :                       $portfolio = array();                      foreach ( $terms as $term ) {                     $portfolio[] = $term->name;                 }                      $portfolio_category = join( " | ", $portfolio );             ?>
             <?php                 $url = site_url();                     foreach ( $terms as $term ) {                         $linklist .= "
slug . "'>" . $term->name . "
\n";                     }                 echo "
" . $linklist . "
";             ?>
                  <?php endif; ?>


title: How can I call a specific file (via php) by referencing the logged-in username?

text: I want to setup a page that will display different content for each registered user of my site who falls within a specially-created user role ('map_user'). So, for example, if a site user who is in the 'map_user' category logs into the site they're automatically forwarded to a specific page. This page then refers to their username, calls specific external content (html) based on that username and includes it in the page. I've managed to solve the first problem (forwarding users based on their user role) through a combination of plugins and functions. But I'm struggling with the second part, once they've arrived at the destination page. I've created a template for the page and included the following php within it:               <?php if ( is_array( $user->roles ) && in_array( 'map_user', $user->roles ) ) : ?>         <div id="mapContent">             <?php require("/mapping/{$user->data->user_login}.html/"); ?>         </div>     <?php endif; ?>      Where am I going wrong? (My php skills are very much of the copy/paste or "steal and adapt" variety, so I'm prepared to have stupid mistakes pointed out to me :) )


title: Help to enqueue a js functions ( jquery)

text: I have this js function (the `textualizer.js` is external) but I can't make it works on WordPress. Any help? I already added               wp_register_script( 'textualizer', WP_THEME_URL . '/assets/js/textualizer.js');     wp_enqueue_script( 'textualizer' );      to theme functions. What am I doing wrong? I know it's probably simple, but I can't figure it out. EDIT: i changed the function in functions.php, a user in irc channel told me that i was missing the correct action hook. still doesn't work... http://pastebin.com/L8ZRSvzU


title: jQuery slider widget similar to cnet.com

text: I'm building a WP theme that requires a splash graphic "slider" widget (similar to what you see on cnet.com). I'd like to build one myself, mainly so I can have full control over the bits, but if there are any available with licensing options for inclusion in commercial shipping software, I'd consider those as well. Does anyone have an example they could share of creating a "graphic slider" widget (or plugin) using the built in WP jQuery script via enqueue? By "graphic slider" I just mean a script that displays a series of named images, along with an index at the bottom that shows the current slide and allows tracking back/forward and to specific slides in the rotation. It would be a bonus, if the widget had a control panel to allow the user to upload/delete each slider graphic as well as define the target URL for each image in a user friendly GUI with upload capability. Thanks in advance for the help. Hope the question is not too conceptual.


title: WordPress Multisite domain mapping with different IPs

text: Hey there, I have 5 different sites with 5 different IP's on cyberwurx shared account. How can I install wordpress multisite and use the domain mapping plugin and also keep my sites on different IP's? Any ideeas? Ty!


title: Adding post-formats to Twenty Ten child theme

text: So I have been building a child theme for a site. Wanted to add post formats to a twentyten child theme. Now, the goal of my child theme is to copy over the absolute least amount of code/templates from the parent as possible. I originally figured if I added additional post formats to a twentyten child theme, using a custom function which uses add_action after_setup_theme, it would work. However, that does nothing. Something like (either with or without the 2 existing formats, doesn't matter):               function voodoochild_setup(){          add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link' ) );     }          add_action( 'after_setup_theme', 'voodoochild_setup' );       The only way I've found to add post formats, is to copy the entire twentyten_setup action to my child functions.php from twentyten, and edit that small portion from there, adding my formats. This works fine, and I'm cool with it. I just want to know if it's necessary. Is there a better way to register new formats onto a child theme without hauling that big block of code over to the child?


title: Using template tags in external JS file

text: I’d like to know how to use the `get_bloginfo( 'template_directory' )` tag in an external JS file. I just found out that it’s possible using the `wp_localize_script` function but I didn’t manage to get it to work … _functions.php_               wp_enqueue_script( 'custom_js' );     wp_localize_script('custom_js', 'wp_urls', array( 'template_dir' => get_bloginfo( 'template_directory' ) ));       _header.php_ (beneath `wp_head();`)               <script>         alert(wp_urls.template_dir);     </script>


title: How to programatically change username (user_login)?

text: As in the title, how to programatically change user's login? I wanted to use `wp_inser_user` function, but it appears that when updating current user, it doesn't change his/hers username. Should I use `$wpdb->update` for that? If yes, how would code for changing username look like? What consequences would changing user login have, given that WordPress API doesn't allow changing usernames? Thanks!


title: "lambda_xx" on all wordpress login pages

text: I have the oddest thing happening on all the Wordpress installations on a single server. I don't know if anyone has seen this or knows what it is. On the login page, there is an error message that says "lambda_49" and every time I refresh the page, the number after the underscore goes up by one. Has anyone seen this before or know what it's about?


title: Wordpress widget args - classname?

text: Could someone explain to me what "classname" in the $widget_ops array means when you're creating a custom widget? It doesn't seem to have any relevance. I've searched both the source and the db and can't find any instance of it.               $widget_ops = array( 'classname' => 'example', 'description' => 'widget description ' );          $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );          $this->WP_Widget( 'example-widget', 'Example Widget', $widget_ops, $control_ops );


title: Shortcode strips formatting and returns at content top

text:
Using the Advanced Custom Fields plugin and I've got a shortcode going for a repeater field, but it returns the list at the content top. I changed it from an `echo` to a `return`, which I understood would fix the issue of it appearing at the top of the content, but it didn't and now it strips all the html out and returns the whole thing as one big text block. Clearly I'm doing something wrong.               function teamlist_shortcode($atts, $content = null) {     if (get_field('aw_team_members')):     while (has_sub_field('aw_team_members')):          $string = '
' . the_sub_field('team_name') . '

' . the_sub_field('team_title') . '
' . the_sub_field('team_bio');          endwhile;     return $string;     endif;      }     add_shortcode('teamlist', 'teamlist_shortcode');


title: Hide allow trackbacks/pingbacks

text: Under the discussion tab on the post page, there's 'allow comments' and 'allow trackbacks and pingbacks', how would I hide the option to allow pingbacks from users but still have it be on by default?


title: How to add custom "Menu Settings"

text: I want to be able to tell the wordpress menu's on what page to show. The way my menu is shown now: ![How it looks default](http://i.stack.imgur.com/lu5Bo.png) I want to have the option in the menu settings like so: ![Where I want the setting](http://i.stack.imgur.com/VouCf.png) But I cannot find any documentation about the menu settings. Did I miss something? I am able to create a list of pages. I just cannot find where I can add these settings. ## Edit I created a workaround. I am using the meta boxes on the pages and a dropdown to select the menu. So now I can choose a specific sidebar menu for each page instead of a menu for specific pages.


title: cloning a WP_Query

text:
I'm working with several nested loops in order to create a statistics table for teams in a league and I'm having trouble getting my original query back. I've read that I should clone the original query but can't find an explanation of how to do it or where to put it. Here's what I've come up with (definitely not working):               $team = new WP_Query(array('post_type' => 'team_page') );      $i=0;          if ( $team->have_posts() ) {     while ( $team->have_posts() ) {          $team->the_post();          $team_id = $team->posts[$i]->ID;             $args = array(            'post_type' => 'match_report',            'post_status' => 'publish',            'meta_query' => array(              'relation' => 'OR',                   array(                      'key' => 'report_home-select',                      'value' => $team_id,                      'compare' => '=',                   ),                   array(                      'key' => 'report_away-select',                      'value' => $team_id,                      'compare' => '='                   )            ),             array(                 'key' => 'report_type',                 'value' => 'cup',                 'compare' => '='                  ),                                            );              $reports_played = new WP_Query($args);          $played = $reports_played->found_posts;         $i++;                  $args = array(            'post_type' => 'match_report',            'post_status' => 'publish',            'meta_query' => array(                array(                      'key' => 'report_home-select',                      'value' => $team_id,                      'compare' => '=',                ),            )                                            );              $hometeams = new WP_Query($args);         $team_is_home =  $hometeams->found_posts;             $args = array(            'post_type' => 'match_report',            'post_status' => 'publish',            'meta_query' => array(                array(                      'key' => 'report_away-select',                      'value' => $team_id,                      'compare' => '=',                ),            )                                            );              $awayteams = new WP_Query($args);                $team_is_away =  $awayteams->found_posts;          $temp_query = clone $wp_query;          if ( $hometeams->have_posts() ) {     while ( $hometeams->have_posts() ) {     $hometeams->the_post();     $scorehome = get_post_meta($post->ID, 'report_homescore', true);     }     } else {     $scorehome = 0;     }     wp_reset_postdata();     $wp_query = clone $temp_query; ?>
                                  <?php the_title(); ?>	                                  <?php echo $played;?>	                                                    9	                                  0	                                  2	                                  	                                  10	                                  33	                                  27
           <?php } ?>


title: Woocommerce add product variations block to my custom template

text: I'm playing around with woocommerce and I followed their instructions to do my own single-product template by copying to my theme's folder within the structure they recommend. So the thing is that the product page is working pretty well, but I'm facing some issues when is a variable product involved. My question is, are there any hook or something to display the variations associated with that specific product, something like when you add product's attributes manually like:               <?php echo apply_filters('single_add_to_cart_text', __( 'ADD TO MY BASKET', 'woocommerce' ), $product->product_type); ?>      That will add the single add to cart button individually, is there a similar code to display the product variations? Thanks a lot.


title: IPN for s2member

text: I want to integrate a local gateway. So planned to receive the response from local gateway to ipnhandler.php (for example) and then ipnhandler will sent post data to s2m via cURL. I need to know how the parameters should be. I've tried with a demo form but nothing was happened, no log, no message. So need your help. Form was               <form action="http://example.com/s2m/?s2member_paypal_notify=1&s2member_paypal_proxy=LocalGate&s2member_paypal_proxy_verification=905e5a3c73480046f4354946788b8ea1" method="POST">     <input type="hidden" name="first_name" value="Tanmoy" />     <input type="hidden" name="last_name" value="SK" />     <input type="hidden" name="custom" value="example.com" />     <input type="hidden" name="item_number" value="1:hello" />     <input type="hidden" name="txn_type" value="w4324rewq423" />     <input type="hidden" name="payer_email" value="1234@mail.com" />     <input type="hidden" name="period" value="30" />     <input type="hidden" name="mc_amount" value="30" />     <input type="hidden" name="recurring" value="1" />     <input type="submit">     </form>      They have a documentation on it also, can be found here.


title: Shortcode for Twitter Bootstrap Collapse

text:
Im trying to create shortcodes for Twitter Bootstrap Collapse. This is what Im trying to achieve:               [collapse-group]       [collapse accordion="#accordionOne" title="my heading1"]some text[/collapse]       [collapse accordion="#accordionTwo" title="my heading2"]some more text[/collapse]     [/collapse-group]      So for example 'my heading1' would show and 'some more text' would be collapsible. Here is the code Im using, the last shortcode [collapse] is causing a server error on my local install.               function collapse-group( $atts, $content = null ) {       return '
"'.$content.'"
';       }       add_shortcode("collapse-group", "collapse-group");          function collapse($atts, $content = null) {           extract(shortcode_atts(array(           'accordion' => '',         'title' => ''           ), $atts));            return '

             "'.$title.'"

"'.$content.'"

';       }            add_shortcode("collapse", "collapse");      I know there are plugins but I'd prefer to have this custom made for this specific instance so I don't have to rely on a plugin with all sorts of other bloat. Im hoping an answer to this question would be useful to others.


title: How can I list posts in an archive but grouped by categories

text: In an archive of a term I want to list the posts but grouped by another taxonomy terms for example im in taxonomy archive "books" list all posts by a taxonomy term of author   * Author      * post     * post   * Author      * post     * post


title: Unable to rename permalink

text: I have a custom content type, `'Events'`. I'm unable to rename the slug of one event from `'2010-2'` to `'2010'`. There are 6 or 7 other entries of the same content type and they're all fine. Here's what I've done:   * Verified no items in the Trash (for every content type, just to be sure)   * Manually removed drafts, autosaves and revisions from the database   * Verified that no other existing piece of content has `2010` in its slug **EDIT** Worth noting that "`/events/2010`" actually redirects to "`/events/2010-2`"


title: Archive Page Isn't Showing Article Excerpts

text: I'm using the _tk theme (bootstrap + _s) and in the reading form I've set the Posts page to a static page because I'm using a static front page. I've also set it to show a summary for each article. The problem is that the page displays the full article, except for the featured image, and I can't find out how to correct it. I know it's using index.php and calling content.php which tests for is_archive to show the excerpt if it's an archive page. For some reason WordPress isn't classifying the page as an archive page. Inspecting the code shows no archive class on the body tag. I added an Archive widget and clicking a link from there displays an archive page correctly. I also added a conditional is_page to the if statement and get the same results. Please enlighten me.


title: Custom admin TinyMCE - order items

text: I would like to know, how can we order wordpress editor buttons? I want to add the "format/style" dropdown after the heading dropdown. ![enter image description here](http://i.stack.imgur.com/mx9hi.png) Here is my code:               function enable_style_dropdown($buttons) {         $buttons[] = 'styleselect';         return $buttons;     }     add_filter("mce_buttons_2", "enable_style_dropdown");               function myformatTinyMCE( $in ) {         $in['block_formats'] = 'Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6';         $style_formats = array (             array( 'title' => 'Testimonial content', 'block' => 'p', 'classes' => 'Testimonial' ),             array( 'title' => 'Testimonial description', 'block' => 'p', 'classes' => 'Job-description' ),               array( 'title' => 'Testimonial person', 'block' => 'p', 'classes' => 'author' ),         );         $in['style_formats'] = json_encode( $style_formats );         $in['style_formats_merge'] = false;         $in['wordpress_adv_hidden'] = false;         return $in;     }     add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );      Thanks


title: Trigger email send after custom post publish

text: I have a custom post type set up so that a user in the role of contributor can create a post, but an administrator has to approve the post and publish it. I'd like to hook into the event when the administrator publishes this post type and then send an email to all contributors that there has been a post. I tried a test email to myself hooking off of 'save_post' when publishing a post and it worked, but I got sent five emails. There's no loop in the function:               add_action( 'save_post', 'clr_test_email' );          function clr_test_email($post_id) {             mail("myemail@gmail.com","        ok hooked into save post","Testing save post trigger".$post_id,"From: crou@zzz.com\r\nContent-Type: text/plain;charset=utf-8");          }      So I'm not sure if 'save_post' is my best bet. There used to be a 'publish_post' hook, but according to the Codex it has been deprecated. Any thoughts?


title: Ajax loop in sidebar to load post titles/categories

text:
I have a sidebar that displays the 20 latest posts, what I'd really like to do is _Ajaxify_ that loop so there's a `load more` button at the bottom. The problem is, it's a fairly complicated loop and getting WordPress to work properly with Ajax is not childs play. I'm fairly familiar with jQuery but I'm no expert when it comes to complicated server side stuff. I've been reading about Ajax and WordPress for days now and I can't get anything to work properly, or at all. I tried this: How can I fetch loop of post titles via AJAX? And it didn't work, gave me a server error. Here's my little loop.   Even if I could just see how to output the post titles, ignoring all the other stuff with an Ajax request I'm sure I could hack away at it from there.   I just can't get it to work, at all.
     <?php         $sidebar_query = new WP_Query(array(             'showposts' => 20         ) );     ?>          <?php while ($sidebar_query->have_posts()) : $sidebar_query->the_post(); ?>
         <?php if(has_post_thumbnail()) :?>
                 <?php the_post_thumbnail('sidethumb'); ?>
          <?php else :?>         <?php endif;?>             <a href="<?php the_permalink() ?>">                          <?php             $cat_names = wp_list_pluck( get_the_category(), 'cat_name');             echo wp_sprintf_l( '%l', $cat_names );         ?>
<?php the_title (); ?>
                              <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
          <?php endwhile; wp_reset_query(); ?>


title: Basics: adding template tag to display custom fields in the post

text: _I've just started learning so this might be a noob question_. > Displaying Custom Fields > > With a Custom Field added to the post, it's time to display your books and > mood to the world. To display the Custom Fields for each post, use the > the_meta() template tag. The tag must be put within The Loop in order to > work. **Many people add the_meta() template tag to the end of their post** > or in their Post Meta Data Section. - Custom Fields on Codex I think I'm misinterpreting the bold part but I tried to add the tag `<?php the_meta(); ?>` in my post and it's not showing up. Screenshot here.


title: change register url on wp-login page

text: I am just trying to change the url of "register" on wp default login page(domain.com/wp-login.php)   1. I want to change the url on register link.   2. when you are on domain.com/wp-login.php?action=register, I want to redirect to domain.com/register I have added redirect link. but it's not working.                RedirectMatch 301 /wp-login.php?action=register$ http://domain.com/register/$1      Am I missing something? I just want to use my register page (domain.com/register/)


title: Disqus comments only show up on newest post

text:
I've setup Disqus comments on our company blog (link) By creating a comments.php file with:

           and on the single.php file               get_template_part( 'content', 'footer' );     if ( comments_open() || get_comments_number() ) {         comments_template();     }     $previous_post = get_adjacent_post( false, '', true );     $next_post     = get_adjacent_post( false, '', false );      but the comments box only displays on the newest post. I reached out to Disqus support but they haven't replied to me since the beginning of the week. I attempted to use the prepackaged Disqus plugin and it did not seem to work at all (didn't display comments anywhere) so that's why I went with the universal javascript version instead.


title: WordPress HTML Menu

text:
I'm trying to get the menu on my WordPress site to append the class like so:

Home

         Subjects

A Subject

Another Subject

Something else here

Nav header

External link

Sign in to externalmemberssite.net

      But I end up with this:

                 Sample Page

      Then this is the PHP code to generate the menu:               $defaults = array(         'menu_class'        => 'nav navbar-nav navbar-right',         'items_wrap'        => '
%3$s
'         );          wp_nav_menu( $defaults );


title: Hook when category is added to post

text: I'm trying to do something when a category is added to post and saved. I thought that using the `save_post` hook would have registered when a category is added to a post, but it doesn't appear to. When I edit a post and do nothing but change the categories for the post, I don't get the `save_post` hook fired (editing the title, body, etc fires the `save_post` hook successfully). Is there another way to use `add_action`/`add_filter` to detect when a category is added to a post?


title: Get the author of the latest revision

text: I would like to display the author (username) of the **latest revision** of a post from inside the loop. I tried `get_the_author()`, which echoes the username and `$post->post_author()`, which returns the user_id, but both return the original post author and not the latest _revisor_.


title: Custom Post Type on Homepage - Studiopress Genesis Framework

text: I have used to below function to register a new 'guide' content type:               add_action( 'init', 'guide_post_type' );     function guide_post_type() {     register_post_type('guides',          array(               'label' => 'Guides',             'description' => '',             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'capability_type' => 'post',             'hierarchical' => false,             'rewrite' => array('slug' => 'guide'),             'query_var' => true,             'has_archive' => true,             'exclude_from_search' => false,             'supports' => array('title','editor','excerpt','comments','thumbnail','author',),             'labels' => array (                 'name' => 'Guides',                 'singular_name' => 'Guide',                 'menu_name' => 'Guides',                 'add_new' => 'Add Guide',                 'add_new_item' => 'Add New Guide',                 'edit' => 'Edit',                 'edit_item' => 'Edit Guide',                 'new_item' => 'New Guide',                 'view' => 'View Guide',                 'view_item' => 'View Guide',                 'search_items' => 'Search Guides',                 'not_found' => 'No Guides Found',                 'not_found_in_trash' => 'No Guides Found in Trash',                 'parent' => 'Parent Guide',                 ),         )      );     }      I want to display these posts on the homepage of my blog along with normal posts. To do that I have created a new `home.php` file with the below code:               remove_action( 'genesis_loop', 'genesis_do_loop' );     add_action( 'genesis_loop', 'custom_homepage_loop' );          function custom_homepage_loop() {     global $paged;     global $query_args;     $args = array(         'post_type' => array('post','guide')     );          genesis_custom_loop( wp_parse_args($query_args, $args) );     }          genesis();      However, I am still unable to see any guide post types on my homepage. Any suggestions?


title: Removing buttons from the editor

text: I have this nice little function to remove buttons from the tinyMCE editor in WordPress, so far I've been able to remove most of the ones I need to.               function custom_disable_mce_buttons( $opt ) {         $opt['theme_advanced_disable'] = 'justifyfull,forecolor,removeformat,justifycenter,justifyright,justifyleft,charmap,indent,outdent,undo, redo';         return $opt;     }     add_filter('tiny_mce_before_init', 'custom_disable_mce_buttons');         The button control list can be found here: http://www.tinymce.com/wiki.php/TinyMCE3x:Buttons/controls The problem is, there's a few more ones I'd like to remove, like the spellchecker and the 'insert more tag', but I can't find documentation anywhere of the codes/names for these buttons to remove them. Any got any info on this?


title: jQuery Ajax() doesn't work when the page is accessed as a WordPress template page

text: In one file (test_ajax.php) I have a which on change loads another page (registration_form_race_type.php) with a short message via jQuery Ajax(). It works fine when "test_ajax.php" is accessed via its absolute URL which is :               http://46.20.119.207/~asuntosf/wordpress_test/wp-content/themes/test_ajax/test_ajax.php      But amazingly enough, the Ajax functionality ceases to work if the exact same page "test_ajax.php" is accessed via its WordPress address which is :               http://46.20.119.207/~asuntosf/wordpress_test/?page_id=13      I insist these both URLs point to the same two PHP files. Here is the code of "test_ajax.php" :               <?php     /*     Template Name: Page Test Ajax 01     */     ?>     <html>     <head>         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>         <script type="text/javascript">             jQuery(function () {                     jQuery('#event_id_from_list').change(function() {                            var event = jQuery("#event_id_from_list").val();                      var data = "event_id=" + event;                              jQuery.ajax({                         url: 'registration_form_race_type.php',                          type: 'GET',                         data: data,                         success: function(data){                              jQuery('#div_race_type').html(data);                          }                     });                          });             });         </script>     </head>     <body>         <select class='required' type="text" name="event_id_from_list" id="event_id_from_list" />             <option value='Paris'>Paris</option>             <option value='London'>London</option>             <option value='Rome'>Rome</option>         </select>            <div id='div_race_type' class='section'>                         <?php require_once('registration_form_race_type.php'); ?>                    </div>     </body>     <html>      And the code of the page called via Ajax, "registration_form_race_type.php" :               <?php if (isset($_GET['event_id'])) echo 'you selected '.$_GET['event_id']; ?>


title: the_time function inside HTML dom parser

text:
I have recently bought a theme, where I want to modify some things. The theme makes use of shortcodes. One of these shortcodes is adding the most recent posts. In these most recent posts is the date not included. I want to add the date, but I found out that these shortcodes are in shortcodes.php, written in some kind of HTML DOM parser??? I tried to add some code, I found out how to make a div and span, but when I add the_time() in the code,it will show up outside of this div and span. I don't know how to fix it.               $html .= '
          '.the_time().'
';


title: WP Rewrite issue

text: I'm trying to build this structure: for single page:               www.example.com/london/restaurants/monrooe/      where:   * "london" is a query var   * "restaurants" is a category   * "monrooe" is the post name. How can I do it? That's code I have so far:               function setup_city_var($vars){            $vars[] = "city";       return $vars;     }               function create_custom_rewrite_rules() {            global $wp_rewrite;       $rewrite_tag = '%city%';            // Add the rewrite tokens       $wp_rewrite->add_rewrite_tag( $rewrite_tag, '(.+?)', 'city=' );            // Define the custom permalink structure       $rewrite_keywords_structure = $wp_rewrite->root . "$rewrite_tag/%pagename%";            // Generate the rewrite rules       $new_rule = $wp_rewrite->generate_rewrite_rules( $rewrite_keywords_structure );            $wp_rewrite->rules = $new_rule + $wp_rewrite->rules;            return $wp_rewrite->rules;     } // End create_custom_rewrite_rules()      It doesn't work, it's a 404 Any Ideas? Thanks


title: Static homepage duplicate issue

text: I already made a post on official wordpress forum,but hava no replay to my question. Also made a search in the forum here and in Google as well but couldn't find solution for my problem. I'm using CMS theme for my website foxcleaners.co.uk with static homepage. The problem is that i have to choose a post which the theme will use as a homepage.OK,i made a post for the homepage and set as noindex,nofollow,but Google has indexed this post!!Also can anyone tell me how Google found this post?There is no links to it.I don't have categories menu on sidebar..?The best solution will be if someone can tell me how to set a unique homepage (without to choose post or page).I love WP but this is huge problem for people like me who wants to use it as CMS system.


title: Disable custom taxonomy on admin bar

text: I created a custom taxonomy and i want to disable the taxonomy to show on the admin bar below my custom post type. How do i disable it?. The reason i want to disable is because the user is not allowed to add a category.


title: How to make post stick to its own div

text: A Wordpress theme has 4 boxes in front page. Each box has its own posts. please see the screenshot http://prntscr.com/1231qw I want to let the user edit the post using admin panel and when he save the post then post will again publish to its original box instead of another location which is usually happened. How can i make a post specific to its div? is there any way? Any advise please?


title: How to change pagination base from slash to query form?

text: Can this function...               function custom_pagination_base() {     global $wp_rewrite;     $wp_rewrite->pagination_base = 'p';     $wp_rewrite->flush_rules();     }     add_action( 'init', 'custom_pagination_base' );      ...be somehow used to change the from of the url from "page/2/" not to "p/2/" but to "?p=2"?


title: How to get URL param to shortcode?

text: I can't find solution for this ... URL: _www.foo.com/some_page/?name=John_ Page content: > Hi [Name]! Worpress still redirects back to _www.foo.com/some_page/_ I tried everything ... I need something like the following in _functions.php_               function name_shortcode() {         return $_GET['name'];     }     add_shortcode( 'Name', 'name_shortcode' );      And on another page: Click here _www.foo.com/some-page/?name=John_


title: How to load JS for specific screen size using wp_enqueue_script?

text: I need a option so that when I am adding some script using wp_enqueue_script it should load for specific screen size. Like when the screen size will be below 768px the script will not load. I am using something like this for now.....               if(!wp_is_mobile()){             wp_enqueue_style( 'wpm_animation_css', get_template_directory_uri() . '/assets/css/animation.css', array(), '1.1', false );             wp_enqueue_script( 'uikit.min', get_template_directory_uri() . '/assets/js/uikit.min.js', array( 'jquery' ), '2.4.0', true );         }      Any help will be really appreciated. Thanks Sabbir


title: Are there ways of logging in that bypass wp-login.php altogether?

text: I have a WP install that's been getting hammered the last couple days by brute force login attempts. The site has the Limit Login Attempts plug-in installed. And when I started getting frequent notifications about lockouts, I decided since I only access the `wp-login.php` file and the `wp-admin` from one place, to block all IPs but my own via `.htaccess`. I've tested the `.htaccess` block by removing my IP from the exception list, and it does indeed block access to wp-login.php. So it appears to work from that aspect. However, even with IPs blocked, Limit Login Attempts keeps reporting (frequent) lockouts from IPs. I thought this was curious, since with the `.htaccess` block in place, it seems as though it should be impossible to get to the `wp-login.php` script to begin with, let alone get so far as having an attempted login get processed by the plug-in. So I tried another experiment: While already logged into WP, I changed the name of `wp-login.php` to `wp-login.xyz` thus disabling the script from running entirely. Even with the login script completely disabled, I still got notices that login attempts are being made and IPs are being locked out. Then I thought perhaps someone's got an auth cookie. So I changed the salts. Still the attempts come. I've looked at the codex for help on the Authentication API, but most of the sources there are incomplete, and in any case I'm not finding how it might be possible to attempt a login other than via `wp-login.php`. So my question is: What, if any, other means of attempting a login are possible without the `wp-login.php` script? And how can any such alternate login routes be disabled? EDIT: .htaccess code (first lines of file): This is in the WP root directory (same location as `wp-login.php`.               <FilesMatch wp-login.php>     order deny,allow     Deny from all          # Allow from this IP address     allow from xx.xxx.xxx.xx  #My IP     </FilesMatch>          ErrorDocument 401 "Sorry. No logins here!"     ErrorDocument 403 "Sorry. No logins here!"


title: Hide username from users list

text: I've hidden the username column from users administration with the following code:               function modify_user_columns($column) {         $column = array(             "cb" => "<input type=\"checkbox\" />",             "username" => __('Username'),             "name" => __('Name'),             "email" => "E-mail",             "birthdate" => "Narozeniny",             "sleva_moto" => "Sleva moto"                   );         return $column;     }     add_filter('manage_users_columns','modify_user_columns');      The problem is I cannot enter details of any user now, as normally the user detatils are accessed when clicking on the username. Is there a way to add the link to detail page to the `Name` column?


title: Extract the last published post in wordpress (3.3)

text: How do I extract the last published post in Wordpress? I would be grateful if someone can just point out the relevant action hooks that I should check out. I have seen publish_post, edit_post, save_post, get_the_tags, sanitize_** functions in post.php but so far no success. I want to export the entire array of the last published post from the wordpress database. How do I do that? thanks.


title: Plugin fatal error

text: I'm trying to activate a plugin I made on a network site. I'm getting an error:               Plugin could not be activated because it triggered a fatal error.      I have the debug mode on and it outputs all errors into a debug.log, however nothing is given for this error. Is there another way to see what the error may be? The plugin registers a CPT with taxonomy. It was recently deactivated to test a few changes I made. Upon the reactivation it is failing. Something to note, the custom post type has 900 posts and 1400 taxonomy terms. Hopefully something comes to light without having to redo all that work for the posts.


title: How do i hide categories from menus which don't yet contain posts?

text: I would like to hide a large number of categories from both the primary and secondary menus which have already been create however don't as yet contain posts. Any PHP code i can use for this as there's a large number of categories.


title: Editing Category RSS Feeds

text: I have the following PHP code below that I would like to add to the category feed in WordPress.               <?php if(get_the_post_thumbnail()): ?>     <featured-item><?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?></featured-item>     <?php endif; ?>      I know that I can edit `feed-rss2.php` to add it into the general feed. But the same code isn't allowing me to add it to the category view of the same RSS feed. Where do I place this code for the generated RSS feed?


title: Custom post types ordering & hooks

text: I have   * `archive-member.php` copy/pasted from the `archive.php` which I use to output the list of all posts with custom post type `member`   * `taxonomy-meber_type.php` file copy/pasted from the `taxonomy_post_format.php` file to output the list of posts (eg.`members`) with taxonomy `member_type` (this is accessed via a menu using the permalinks to each taxonomy value & slug , eg. : `type_de_membre/membre`, `type_de_membre/membre-honoraire`, etc...) as per here. This works perfectly, but I would like to order this output by `member_lastname`, which is a custom field added using ACF, related to the memeber custom post type. I have adapted the hook in the codex to list all the relevant posts(members...), which seems to work fine for the pages where taxonomy is defined (eg. `membre/membre`) but not on the `archive-member.php` file listing all posts with `post-type="member"`, but can't make the one for listing alphabetically work at all, on whichever page: I have copied below the 2 hooks. I'm ok with PHP mysql queries, but a real newbie to fiddling with the hooks & generally with WP queries etc, so bear with me & thanks for your explanations. Both hooks as I adapted them:               add_filter('posts_orderby', 'member_alphabetical' );     add_filter('post_limits', 'member_limits' );          function member_alphabetical( $orderby )     {      /* global $gloss_category;*/     if( !is_admin() && is_post_type_archive('member_type') ){     /*  if( is_tax( 'member' )) {     */     // alphabetical order by custom field 'member_lastname'          return "member_lastname ASC";     /*  }     */       // not in glossary category, return default order by       return $orderby;     }      }          function member_limits( $limits )     {       /*global $gloss_category;*/          if( !is_admin() && is_tax('member_type') ){          // remove limits          return "";       }            // not in glossary category, return default limits       return $limits;     }      Thank you !


title: Enqueue Javascript Correctly for 3.5

text: I am trying to create tabs for admin settings page in wp, but I think I'm doing it wrong. The example below shows how I did it but I don't know how to change this to use it correctly with no conflict ie. $.               function my_plugin_load_js() {     wp_deregister_script('jquery');     wp_register_script('jquery', 'http://code.jquery.com/jquery-1.8.3.js');     wp_enqueue_script('jquery');          wp_deregister_script('jquery-ui-core');     wp_register_script('jquery-ui-core', 'http://code.jquery.com/ui/1.9.2/jquery-ui.js');     wp_enqueue_script('jquery-ui-core');     }     add_action('admin_enqueue_scripts', 'my_plugin_load_js' );          function mypluginjs() {     echo '<script type="text/javascript">     jQuery(function() {        jQuery( "#tabs" ).tabs();     });     </script>';     }     add_action( 'admin_print_scripts', 'mypluginjs' );


title: WordPress navigation only shows post of page one, even if on page two

text: Got a little problem hopefully I can get some help. I noticed that after I added a "sort post by" code to my index my navigation broke. If you click on page two you still get the contents of page one. I did a little digging and found the problem, only thing is I not sure how to fix it. Here is the loop from my index page. Now I need to exclude a selected category from the main loop, that's the first part. The second part is if I add $orderby to the query_posts string (second to the last line) then the navigation breaks. If I remove it then it works. I tried to have to query_posts strings, but that didn't work out. Anyway to make this work or do I have to give up one for the other?                       <?php         $featcat = get_option($shortname.'_featured_category');               $category_id = get_cat_ID($featcat);     $paged = (get_query_var('paged'))?get_query_var('paged'):1;     $q = array();     $q['category__not_in'] = array($category_id);     $q['paged'] = $paged;     query_posts($q.$orderby);     if (have_posts()) : while (have_posts()) : the_post(); ?>


title: Using GROUP CONCAT in my-sql query with wp_usermeta table

text: I have a query that is meant to return user details from Wordpress tables. It would be fine if I was just SELECTing column names that I want, but within Wordpress there is a usermeta table which has 2 columns - 1 called metakey and 1 called meta value. I want to get certain bits of user info from meta keys such as first_name and last_name, but they are all within the same column - metavalue. Here is what I have:                   $allquery="SELECT $comma_separated, wp_usermeta.meta_value, wp_usermeta.meta_key,      //comma_seperated are a list of values to search for seperate by ",". this is name, email         GROUP_CONCAT(             wp_usermeta.meta_value             ORDER BY wp_usermeta.meta_key         ) AS name         FROM wp_users         LEFT JOIN wp_usermeta         ON wp_users.ID = wp_usermeta.user_id         WHERE  (wp_usermeta.meta_key = 'first_name'             OR wp_usermeta.meta_key = 'last_name')             AND wp_users.user_login = '$spec_user'         GROUP BY wp_users.ID";              $names = array();         $allresult=mysql_query($allquery) or die(mysql_error());               while($rows=mysql_fetch_array($allresult)){                    $names[] = $rows['name']; //name is from the group_concat in query             $emails[] = $rows['user_email'];          }      The problem is, this just returns a single row. I think it could be something to do with the line: AND wp_users.user_login = '$spec_user' Where $spec_user is a user entered value. What I want ideally is all rows returned where the user_login column equals what the user has entered. Not just from that table, but from the usermeta table.


title: Exclude the first 'n' number of posts of a tag from home page?

text: **Use case (example):** Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query. I don't want the 5 featured posts, i.e. the first 5 posts tagged 'highlights', to appear among the latest posts. To put it another way, the latest posts should include all the latest posts, but in doing so, if it finds a post is tagged 'highlights' and is among the first 5, it should be excluded. All this, without breaking the pagination. How do I do this? * * * I have faint idea as to how I can do this:               function itsme_filtered_latest_posts( $query ) {              if( $query->is_home() && $query->is_main_query() ) {                  $query->set( ... );                  $query->set( 'offset', ... );              }          }     add_action( 'pre_get_posts', 'itsme_filtered_latest_posts' );      Like I said, I only have a faint idea, which is as good as having none.


title: Does Wordpress perform better with curl installed?

text: Wordpress doesn't require curl but it seems to use it if it's available (see line 295). I'm guessing HTTP requests will perform better using curl or Wordpress wouldn't even try to use it. Is this true? And if so, what evidence (scientific or intelligent guess) is there that this is true?