title: Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?

text: My plugin code is below. In the myPlugin_cleanup() function, I'm creating some categories and assigning term id 1 as the parent. Due to the **known bug with creating categories via script** (the category_children array does not get created and results in a fatal error when pages containing category listings are accessed), I've placed the clean_term_cache() call directly below the function that creates my categories. However, its not working. The category_children option is not getting created. Interestingly, if I create a plugin whose sole function is to execute the clean_term_cache('','category') call, it fixes the problem and creates the category_children option with the correct values. I'm just not sure why its not working in the same plugin that creates the categories. What might I be missing?               function myPlugin_activate(){         if ( get_option( 'myPlugin_activated' ) !== "1"){             //comment out any function you don't want to run             myPlugin_copy('themes');             myPlugin_copy('plugins');             myPlugin_images();             myPlugin_options();             myPlugin_settings();             myPlugin_widgets();             myPlugin_links();             myPlugin_posts();             myPlugin_pages();             myPlugin_custom_menus();             myPlugin_cleanup();             clean_term_cache('','category'); //does not work here             update_option('myPlugin_activated', "1");             }         }          function myPlugin_cleanup(){                  //include dependencies             require_once(ABSPATH.'/wp-admin/includes/taxonomy.php');                      if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}             if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}                  clean_term_cache('','category'); //Does not appear to work here either.             }               register_activation_hook(__FILE__, 'myPlugin_activate');     ?>


title: Favorite recent post widget

text: Does anyone have a favorite widget for the sidebar that would show the last three posts with: Title Some of the content... read more


title: List WordPress Custom Menu's active parent level's children as separate menu

text: I have a structured Custom Menu:   * parent 1      * children1_1     * children1_2    * parent 2      * children2_1     * children2_2    * parent 3    * parent 4      * children4_1 etc. I want the following: on every page, the parent level items will be shown as main menu. If a parent level item is active, I want to show the child menu items as a separate list somewhere else in the page. Is there an "easy" way to achieve this, or do I have to list the menu every time and select the current one with PHP and have headache for this for days? :) Thanks, cadeyrn


title: Body text disappearing in random posts

text: I'm using Wordpress 3.5.1 I noticed recently on my site that the body content of some posts is disappearing. The post still exists, all the other fields are still populated, but the post_content field is empty. It seems pretty random -- different post types; sometimes it happens immediately after content is created or updated, other times after it's just been sitting there untouched for weeks or months; some with complicated content, others with plain, short text entries. I checked the database, and the post_content fields for these posts were empty. Often times, there was a separate autosave record that contained the post body, luckily. I've been using those to re-add the missing content. Any ideas what could be causing the problem?


title: Custom Post from Custom Query with Multiple Custom Taxonomy Terms with Pagination

text: I have a page template like having code, (on the link below) http://pastebin.com/mZaRLKp2 Actually it's the problem of getting custom post list having all the multiple custom taxonomy terms with pagination. This type of problem have been discussed on internet many places but I am yet to get a clear understanding of how to solve. The loop gives me list successfully on page 1 but when I go for next pages my custom query doesn't work instead default query works. I have a custom post 'volunteers'. It has custom taxonomy of 'lgroup' and there are some types of 'lgroup' like 'location', 'group_type', 'meeting_day' etc. I want to filter the list of post only having combination of particular 'location' and 'meeting_day'. I create a form choosing them and 'POST' request for the form to submit. Because when I make this 'GET' request my custom taxonomy didn't appear to work in url and redirect to home page. When I use 'POST' request to get custom terms it works for first page but lost on next page and default list of 'volunteers' type post appears. Could anyone tell how to cary forward or maintain the custom query on all pages in pagination. I am really tired to search the solution for this. It would be nice if somebody explain the solution. I desperately want to know how to maintain the custom query with pagination. One more question ? I wanted to list posts only having both terms but IN operator in 'tax_query' work like 'OR' operator it lists post belongs to any terms belongs to but I want post only when it associates to both the terms. Currently I am collecting the terms and excluding them with all the terms and used rest array for with NOT IN operator in 'tax_query'. Is there any way to list post having both the terms 'group_type' and 'location' in my code. So there is two questions? 01 >> Custom query with pagination, Pagination really sucks me yet. Please help me somebody. 02 >> having multiple custom taxonomies only and only if custom post belongs to both terms not one of them.


Can one plugin activate another plugin via script? I know its possible to deactivate known plugins via script, but can't find any examples of how to activate them.


title: Additional page and post status types

text: I have a site where pages will often move from draft to published and then to legacy. I would like to create another status type similar to draft or published titled "legacy". Wherein the page exists but is indicated as no longer active on the site. Is anyone aware of a Plugin or way to hack this feature?


title: Login to wordpress by clicking a link and specifying usernaname and password in url

text:
I'm running a php application on an ubuntu server that's completely independent of my wordpress site. I'm using an iFrame of the server inside the wordpress site, but I need to login to Wordpress with it (because I need to pass `$token` and `$videoid`). On the Ubuntu server, I have a form that looks like this:               <form target="_top" action="http://website.com/login/?token=<?=$token?>&videoid=<?=$videoid?>" method="post">
     <input placeholder="Email Address..." type="text" name="email" id="email">

     <input placeholder="Password..." type="password" name="password" id="password">

          <input type="submit" value="Submit">     <input type="button" value="Cancel" onclick="document.getElementById('create').style.display='none';">     </form>      I'm successfully passing the username, password, token and videoid to a login page on the wordpress site, but the best I've been able to do on that page is create a new form with those values. Is there any way I can auto-login on that page using the credentials passed from the form on the other server?


title: Add new media uploader at frontend for wp 3.5+

text: I create a form for user to submit content from the frontend. The only problem is I don't know how to handler the image upload. So, I want to know how to use the WP media uploader in the frontend. The media uploader should be appeared like in the 'wp-admin/media-new.php'. I don't want the pop up version of the uploader, as it seen in post/page page. Because it has other feature that I don't want user to use, such as 'Media Library', 'Create gallery', 'Set Featured Image' etc. Is there any tutorial or documentation on how to do it? Thanks


title: BuddyPress - User Login instead of Full Name

text: Im trying to display user login instead of user full name below each post avatar. Im using the following hook:               function my_member_username_link() {              global $post;              if (isset($post->post_author)) {                $user_info = get_userdata($post->post_author);                return 'user_login . '/" title="' . $user_info->user_login . '">' . $user_info->user_login . '';                    }                }          add_filter('bp_core_get_userlink','my_member_username_link');      This works on each avatar close to each post, but acts weird in the right sidebar where my session is displayed. Any help is welcome. Thanks in advance.


title: How to insert an Audio Player in a Post or Page?

text: I have a blog which I sometimes use for audio clips. I want to put an Audio Player on the frontpage of my blog. How can I put the player after the title or make its code part of post excerpts?


title: How does one include the JQuery UI plugin to wordpress and enque it correctly in a plugin form?

text:
I have a basic admin top-level plugin I wrote which has a submenu driving a php form with a grid table populated from wp_dbase (from a custom table 'Branches' in it). My installation is a _clean_ WP 3.3.1 on WAMPServer. Only changes are including the before the wp_head function in the , in the header file for both 2010 and 2011 themes. My attempt at using JQuery 'Document.ready' does nothing. So I assume I have a Jquery setup problem. Any pointers / help would be much appreciated. (I have tried using JQueryUI dialog - modal - form as well, but zilch, nada,... Also the 'pop-up div' shows in the page, and does not 'popup'. My form and Jquery function beneath.
     <form name="Sandwich Baron Branch Maintenance" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">          $(document).ready(function(){        alert("We're in Jquery world");             $('#form-wrap').dialog({             autoOpen: false, //FALSE if you open the dialog with, for example, a button    click                         title: 'My Form',             modal: true             });     });       and here the #form-wrap div it references

All form fields are required.
     <form>        <fieldset>         Branch Name         <input type="text" name="txtBrname" id="txtBrName" class="text ui-widget-content ui-corner-all" />         Tel         <input type="text" name="txtTel" id="txtTel" value="" class="text ui-widget-content ui-corner-all" />        </fieldset>     </form>


title: How to manage a standalone media folder?

text: Managing my Wordpress installation with Git is great. I get to deploy fixes via command line (with Capistrano), easy rollback plan, the Theme folder is a standalone project added as a submodule -- This seems like a good way to handle Wordpress' and its plugins rapid updates. However, Source Control is not right for handling the on-growing Uploads folder under `wp-content` folder. The solution, IMHO, was to create a dedicated part on my server for media, and exclude it from the project itself. This way, I can backup media in a standalone process, deploy new version without having to clone the entire 300MB folder again and again -- in short, this seems like a good solution. Wordpress doesn't do that, though. Not out of the box. Possible solutions:   * Uploads files via FTP and use the image URL in posts (doubles the posting process time)   * Use a 3rd party image hosting (Flickr, Tumblr) -- This creates a dependency I wish to avoid. I want the media on my server, under my control. Any other ideas? How can I achieve a standalone media folder to which I can upload files from WP dashboard?


title: value not set in contact form 7 plugin of wordpress

text: i'm using contact form 7 plugin in wordpress,   i have generate text field like this:                [textarea your-message 25x3 "<?php  print_r($_POST); ?>"]       i have to set value of input name which comes from another form with POST method. but it's not worked, instead of input tag, it displays `; ?>"]` there is any solution?


title: Blog installed in subdirectory but need to create pages in root. How to use permalinks?

text: Our companies blog is installed in `/blog`. Our permalink structure is `/%postname%/` so posts currently look like `https://www.domain.com/blog/post` We've been asked to publish a series of guides which must be installed in `/buying-guides/` e.g. `https://www.domain.com/buying-guides/kittens` i.e. outside of the WordPress folder. I thought the answer was to simply create a page called buying-guides and then create a page per guide as children. We then end up with URLs such as https://www.domain.com/blog/buying-guides/kittens. I then created an `.htaccess` rule in our root folder with               RewriteRule ^buying-guides/(.+)$    /blog/$1 [L,NC]      and it seems to be working beautifully! Until I realized that, there is more to it as WordPress is obviously not aware of the rewrite. For example, we use `the_permalink()` function to generate the link in our page titles and this now obviously generates the incorrect link (although it would still work, but we don't want customers too see any mention of `/blog/` when browsing the buying guides. Is there a good solution to the above issue? Perhaps a filter than automatically changes all URLs just before the page is rendered from `/blog/buying-guides/` to `/buying-guides/`? Any help would be greatly appreciated!


title: Limit the amount of words displayed by the Latest News plugin, or recommend an alternative

text: I am using the Latest News plugin (made by James Piggot, plugin website is here) and I have inserted code that displays 5 of the latest news items in the sidebar area. It's working fine, and displays all I need it to display. However, I want to be able to display the first few lines of the news article with a "Read More" link after it. There doesn't seem to be a way to do that with this plugin, and instead it displays the entire contents of the latest news item in the side bar. Does anyone have any experience using this plugin who could help guide me to restricting the amount of the post it displays? If it can't be achieved using this plugin, is there a plugin out there that I could use that would allow me to do what I need to do? Many thanks!


title: When at / ( or "home") my menu doesn't get a current-menu-item class

text: I'm a wordpress noob tweaking a theme, so I'm trying to understand how it works. I've read about 10 related posts in SE but don't get it yet. My problem is as follows: header.php seems to generate the menu with,               <?php wp_nav_menu(array('theme_location' => 'nav-menu','container'  => 'div', 'container_class' => 'menu' )); ?>       In the wp-admin, I've created a menu with "Blog | About | Contact" which point to the root and two pages: "/" | "about" | "contact" (very standard). Now, I'd like to style the menu depending on the " _active_ " page. For " _about_ " and " _contact_ " this seems very easy. The classes generated for each menu item include **current-menu-item**. However, when on the home page my "blog" menu "li" only gets the classes               menu-item menu-item-type-custom menu-item-object-custom menu-item-47      and so cannot be styled accordingly. I've read some stuff about filtering, using functions, etc ... but don't quite understand it. If I define a function in functions.php, where would I use it afterwards. Any insight and help is greatly appreciated,


title: Delete user after Contact Form 7 submission

text: I need to allow users to delete their accounts on the front end, but need to collect some information about their reason for leaving. I'm using Contact Form 7 to collect the info, and want to use a hook to delete the user. When I use the function below, I receive an email with the info from the form, but it doesn't delete the user.               function outta_here() {              global $current_user;         $delete_me = get_currentuserinfo();              wp_delete_user($delete_me->ID);     }     add_action( 'wpcf7_before_send_mail', 'outta_here' );


title: How to make a video play for homepage?

text: I would like to add a video (autoplay) before the visitor go into my wp blog (maybe just the homepage, not every post), how could this be possible? I think javascript maybe the best choose? Could you give your solution (no matter js or not) in detail? * * * EDIT: After a while, I think this should work for me, but the fact is not, why?               document.write('<style type="text/css">\n\      #wrapper, #header, #footer{ display:none;}\n\      </style>\n\      <video id="loadDiv" preload="auto" data-setup="{}" loop="loop"\      webkit-playsinline="" style="position: absolute; width: 100%" autoplay=""\       src="http://srcofvideo">\      </video>'     );          window.onload = function() {      setTimeout(function () {     document.getElementById("loadDiv").style.display = "none";       document.getElementById("wrapper").style.display = "block";          document.getElementById("header").style.display = "block";          document.getElementById("footer").style.display = "block";      },10000)}


title: Function filter breaking tag archive menus

text: Ok, I'm setting up a site with a some CPT's. When creating posts under said CPT's, we added tags. When viewing the posts results after searching, tags were displayed, but upon clicking the archive page indicted that no results were available. So, I added the code below to my functions.               function myTagFilter($query) {     $post_type = $_GET['type'];     if (is_tag()){         if (!$post_type) {             $post_type = 'any';         }         $query->set('post_type', $post_type);     }     return $query;     };     add_filter('pre_get_posts','myTagFilter');      Now, posts from the CPT's display in the tags archive, but the menu is broken. Here's a link if you want to test it out. http://mt-spacehosting.com/fisheries/?s=framework+50 So, my question is, why would the menu break because of this?


title: Function prints post meta data does not work

text: I modified this code from the Twenty Eleven theme but it doesn't work and I cant see why.               if ( ! function_exists( 'theme_post_meta_data' ) ) :     /**      * This function prints post meta data.      *      * Adopted from Twenty Eleven      */     function theme_post_meta_data() {         printf( __( '%1$sPosted on %2$s by %3$s', 'theme' ),             esc_attr( ''),             sprintf( '%4$s',                            esc_url( get_permalink() ),                 esc_attr( get_the_time() ),                 esc_attr( get_the_date( 'c' ) ),                 esc_attr( get_the_date() ),             ),             esc_attr( sprintf('%3$s' ,                 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),                 esc_attr( sprintf( __( 'View all posts by %s', 'theme' ), get_the_author() ) ),                 get_the_author() , ),             ),         );     }     endif;      I get a HTTP Error 500. Thanks


title: Restrict dashboard access for specific user roles to specific actions

text: I have a script that enables a logged in user (role Author) to delete their own posts using `get_delete_post_link()`. However, I also want to be able to restrict the author's access to the dashboard. Any attempt to do so using a plugin (Theme my Login, for example) or a simple script like those linked below disables my ability to use `get_delete_post_link()`. Is there a way to restrict access to the dashboard for the "Author" user role while still permitting the deletion of posts via `get_delete_post_link()`? http://www.tutorialstag.com/restrict-wordpress-dashboard-access.html How to restrict dashboard access to Admins only?


title: How do I append multiple taxonomies to the URL?

text: # Multiple taxonomies in URL ### How does one append multiple taxonomies to the URL having the following: >   * Post Type: **products** >   * Taxonomy: **product_type** >   * Taxonomy: **product_brand** >    ### Adding new product and selecting type and brand for this product:   When adding a new **_product_** , there are two taxonomy boxes (product_type and product_brand). Let's call this new post **_Test Product 1_**. The first thing we want to do is tick what type of product I'm dealing with, let's say **_cell-phones_**. Next, I want to tick what brand the product belongs to, let's say **_samsung._** Now " ** _Test Product 1_** " is associated with the type **_"cell-phones"_** and the brand **_"samsung"_**.   **The desired end result is:** > **/products**   >  » View all custom posts > > **/products/cell-phones**   >  » View all custom posts with the taxonomy cell-phones > > **/product/cell-phones/samsung/**   >  » View all custom posts where the taxonomy is cell-phones **AND** samsung > > **/products/cell-phones/samsung/test-product-1**   >  » View the product (single custom post)    ### The question How would one make this possible? My initial thought was using one taxonomy, having **_"cell-phones"_** as the parent term of **_"samsung"_**. Actually appending the taxonomy and its terms was not so tough. But it led to a lot of other issues, some well known, some not so much. Anyway it doesn't work like that as it gives 404 issues and WP won't allow certain things.   WP.org » taxonomy-archive-template This lead me to having rethought the structure, having to leave taxonomies and its terms and I thought; why not create a 2nd taxonomy, and associate the post type with it and append that to the url? Good question indeed, but how?


title: Check if current page is the Blog Page

text: I'm new to _Wordpress_. I need to check in header file if current page is the **Blog Page**? I checked but I can't find the way. Help me, Pls.


title: how to edit wp category widget

text: how to edit wp category widget, so it would not show one of specified category? For example, it shows all categories in list, and I need to remove category Books, from it, how can I do it? Best regards, Y2ok


title: remove featured image from gallery woocommerce

text: I am using wooCommerce. When i set the featured image for a woocommerce product, it shows up as the first/main image in the gallery on the product details page. I need to remove the featured image from the gallery only. How to do this?


title: Mass Update User Profile Checkbox Options

text: I created a checkbox option for the user_meta (user profile). They are checkboxes assigning users to categories. The problem is that I need to do a mass update for all of my users 1500+ and going through them individually would take too long. I need to choose the intended categories for each user. There are 180 categories. This is a screen shot of the section of the user profile that I want to update: ![enter image description here](http://i.stack.imgur.com/JVFHx.jpg) I need a way of doing this. Im open to using a custom script (preferably not a plugin), csv import, or any other options. The purpose of the category selections is so that I can save their descriptions in a meta field that will then be searchable with a custom query. This won't work if the users dont have a category(ies) selected. It's a pain now because there is a large amount that I need to do at once, but ideally the categories will be selected as new users are created. Anyone with a way of achieving this please help. Please let me know if there is any additional info needed. Thanks a lot


title: Delete all thumbnails for a post

text: I have a function that sideloads a YouTube thumbnail onto a page... but I want to remove the featured thumb on the page first (and remove all the various auto-generated sizes, too). I'm assuming I want to use `delete_post_thumbnail()` followed by `wp_delete_attachment()` to un-associated the thumb from the post, and then kill the thumb file. Is that correct? And Will that also delete all the various thumb media files (the extra auto-generated sizes) from the disk?


title: How to create a page with links to other pages that include image and excerpt?

text: I have several pages (not posts) on my Wordpress site. They contain excerpts (I forgot which plugin enabled that) and have an article image. Now I would like to create another page that contains selected links to those pages. I would like to just select the pages and have those links created automatically with the excerpt text and the picture. I found a plugin which does that, and it looks ok. It's just that the plugin is quite old and has not been updated for two years or so. I searched a really long time now and have not yet found any. Is there another way to achieve this?


title: Redirect blog archive into certain format

text: My blog archive URLs were like:               http://example.com/2014/03      I changed my site's permalink from `/%postname%/` to `/%postid%/%postname%/`, and using Redirection plugin, I set a redirection like: ![redirection 1](http://i.stack.imgur.com/mOLdu.png) and it's working. But the problem occurs in the archive URLs. The new archive URL generated with a /date/ basename before the dates, like:               http://example.com/date/2014/03      I'm trying to use the same Redirection plugin to redirect the URL, but failed: ![redirection 2](http://i.stack.imgur.com/FTtUs.png) I then tried writing `.htaccess` on my own (with no `.htaccess` writing experience) with:               Redirect permanent http://example.com/([0-9]+)/([0-9]+) http://example.com/date/([0-9]+)/([0-9]+)      with the help of htaccess editor and this blog. But failed too. How can I let my blog not to get 404 on such archive URL? I'm afraid, I'm dumb with rewrite rule till now. :(


title: Checking that the Rewrite API is available

text: WordPress supports URL rewriting through the Rewrite API. It relies on underlying HTTP server mechanisms to get the job done. It is not always possible for WordPress to enforce the Rewrite rules. For example, with Apache, when WordPress isn't allowed to create the .htaccess file. The plugin I'm writing should take advantage of the Rewrite API, when it is available. Basically:               if (is_url_rewriting_available( ) ) {         Plan A     } else {         Plan B     }      But I can't find such function. What I investigated so far:   * Nothing in the doc, in particular in https://codex.wordpress.org/Class_Reference/WP_Rewrite   * "Write" functions, such as `flush_rewrite_rules`, return nothing. So it can't be used to check the availability (eg. `if (false == flush_rewrite_rules () )`).   * In `wp-admin/options-permalink.php`, around line 130, the code checks URL rewriting requirements. However, this code doesn't seem to be reusable. Sure, I can copy/paste this code but...


title: Giving auto update functionality to my theme

text: I have created a free wordpress theme. I want to give the users the ability to auto update the theme from the dashboard if there exists a update in mysite. We can see that when we are using wordpress.org themes right? Please tell me what is the solution for that?


title: How to move theme directory but not plugins/uploads out of WordPress root directory?

text: I am trying to set up a few local multisite installs that will share the same themes folder, but have separate upload and plugin folders that will be in the usual places in `wp-content`. UPDATED: WordPress is installed at `/Users/josh/Documents/Websites/themedev.dev/` and I've create the new theme directory at `Users/josh/Documents/jp-content/jp- themes` and put twenty twelve into it for testing purposes. Per Otto's suggestion below I created and activated a plugin that is just this:               $directory = '/Users/josh/Documents/Websites/jp-content/jp-themes';     register_theme_directory( $directory );      That showed twenty twelve in the theme admin page, but on the front-end I got a blank page, and the page source was totally empty. When I changed the first line to `$directory = '/Users/josh/Documents/Websites/jp-content/jp-themes/' (note the trailing slash,) I got the theme, but not the style. When I echoed the value of`get_template_directory_uri()`I got`Users/josh/Documents/Websites/jp- content/jp-themes//twentytwelve`which would explain it. I tried using`trailingslashit` instead of adding the slash like this:               $string = '/Users/josh/Documents/Websites/jp-content/jp-themes';     $directory = trailingslashit( $string );     register_theme_directory( $directory );      and got the same results. I still can't figure out what I'm doing wrong here...


title: Query for draft or scheduled post

text: What should be the query for checking if there is any draft or scheduled post, I'm not able to make which arguments to take. Thanks


title: Automatically add image caption with values from a post parent field?

text: i have a custom dropdown field on post and i would to get the value from that custom field and insert it on each image caption field uploaded to the current post. I have been looking for a way to do this and found a couple of examples but not even one work. This morning i found a Wordpress filter that is called attachment_fields_to_save. To my surprise on the codex was an example of almost the same thing i was looking for but i didn't work. This is the code               function insert_custom_default_caption($post, $attachment) {     if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {         if ( strlen(trim($post['post_title'])) == 0 ) {             $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));             $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');         }              // captions are saved as the post_excerpt, so we check for it before overwriting         // if no captions were provided by the user, we fill it with our default         if ( strlen(trim($post['post_excerpt'])) == 0 ) {             $post['post_excerpt'] = 'default caption';         }     }          return $post . $attachment;     }          add_filter('attachment_fields_to_save', 'insert_custom_default_caption', 10, 2);      Can anyone help me to see what is wrong with that code?


title: Enable Woocommerce chart, price and buying functions if only user is specific role, otherwise use as catalog

text: I would like to make a e-commerce site that use as catalog for visitors or users that less than specific role capabilities.   Eg: if i enable the woocommerce for Editors than editors and above will be capable to see prices, add to chart and check-out (chart visibility and functionality), all other members and visitors will only can see the products as catalog.   I've tried many things but most of them just for logged/visitor seperation.   Thanks right now.


title: Automatically add widgets to all pages

text: I have created a few pages and made them into menus. Also i'm using widgets on pages. Some of the widgets should be in all pages. In every page i need to add a short-code to that widget. Is there any way to automatically add widgets to all pages? Maybe i should i alter the edit.php source code?


title: wp_enqueue and Dependencies

text: Easy Question: If I enqueue a script as follows: Version A:               wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));      Do I need to enqueue jquery and jquery-ui-core? As below: Version B:               wp_enqueue_script( 'jquery' );     wp_enqueue_script( 'jquery-ui-core' );     wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));      Or does listing the scripts that it's dependent on (as in Version A) automatically handle that?


title: Attempt to improve WP search, can someone check my SQL query?

text: I'm stumped. I've done a bunch of work to filter what posts get pulled in a WP search and then even more work sorting those after they're pulled from the DB. My main problem now is getting results matched by Tag. I've just been running the straight SQL query and checking the output rather than running it through WP over and over. First the search query as WP generates it (my filters added and I've expanded out the important part):               SELECT SQL_CALC_FOUND_ROWS       wp_3_posts.ID FROM wp_3_posts       LEFT JOIN wp_3_term_relationships AS trel ON (wp_3_posts.ID = trel.object_id)     LEFT JOIN wp_3_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'post_tag' )       AND trel.term_taxonomy_id = ttax.term_taxonomy_id)      LEFT JOIN wp_3_terms AS tter ON (ttax.term_id = tter.term_id)       WHERE 1=1       AND      (      (       (        (         (wp_3_posts.post_title LIKE '%neck%')          OR         (wp_3_posts.post_content LIKE '%neck%')        )         AND         (         (wp_3_posts.post_title LIKE '%pain%')          OR         (wp_3_posts.post_content LIKE '%pain%')        )       )        OR        (        (         (tter.name LIKE '%neck%')         AND         (tter.name LIKE '%pain%')        )        OR         (tter.name LIKE '%neck pain%')       )         OR        (        (         (wp_3_posts.post_excerpt LIKE '%neck%')          AND         (wp_3_posts.post_excerpt LIKE '%pain%')        )         OR        (wp_3_posts.post_excerpt LIKE '%neck pain%')       )       )     )       AND (wp_3_posts.post_password = '')       AND wp_3_posts.post_type IN ('post', 'page', 'attachment', 'syndicated')      AND (wp_3_posts.post_status = 'publish')       ORDER BY wp_3_posts.post_date DESC LIMIT 0, 7      The first part which grabs the necessary tables with joins seems to be just fine. The search I'm running is for "neck pain" and any posts with those words in the title, content, or excerpt show up as expected. I have one post tagged "neck", "pain", and "neck pain". That post ID does not return with this query. What driving me nuts is that if I remove the part of this query that looks into the post_content and post_title, my tagged post _does_ show up. Specifically, if I remove this:               (((wp_3_posts.post_title LIKE '%neck%')      OR (wp_3_posts.post_content LIKE '%neck%'))      AND ((wp_3_posts.post_title LIKE '%pain%')      OR (wp_3_posts.post_content LIKE '%pain%')))      OR       which leaves my query as               SELECT SQL_CALC_FOUND_ROWS       wp_3_posts.ID FROM wp_3_posts       LEFT JOIN wp_3_term_relationships AS trel ON (wp_3_posts.ID = trel.object_id)     LEFT JOIN wp_3_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'post_tag' )       AND trel.term_taxonomy_id = ttax.term_taxonomy_id)      LEFT JOIN wp_3_terms AS tter ON (ttax.term_id = tter.term_id)       WHERE 1=1       AND      (      (        (        (         (tter.name LIKE '%neck%')         AND         (tter.name LIKE '%pain%')        )        OR         (tter.name LIKE '%neck pain%')       )         OR        (        (         (wp_3_posts.post_excerpt LIKE '%neck%')          AND         (wp_3_posts.post_excerpt LIKE '%pain%')        )         OR        (wp_3_posts.post_excerpt LIKE '%neck pain%')       )       )     )       AND (wp_3_posts.post_password = '')       AND wp_3_posts.post_type IN ('post', 'page', 'attachment', 'syndicated')      AND (wp_3_posts.post_status = 'publish')       ORDER BY wp_3_posts.post_date DESC LIMIT 0, 7      Maybe there's something I'm not understanding about SQL here, I'm a bit of a hack at it. Any wisdom would be much appreciated, thanks!


title: do_shortcode within post query

text:
I am querying blog posts with a specific category (according to the template page slug, and want each post to output a slider, title and content. I'm using the wordpress plugin Anythingslider for Wordpress. I am creating slides with the same category as the post slugs so that everything is automated and less copy and paste - however when I add the do_shortcode line, it duplicates the same post (for as many times as there are posts), instead of displaying EACH post! Anyone have any ideas?                   <?php        $args = array(         'post_type' => 'post',         'category_name' => $post->post_name,         'showposts' => 20,      );          $the_query = new WP_Query( $args );           $page_id = get_the_ID();     $page_object = get_page( $page_id ); ?>

<?php echo $page_object->post_content; ?>

Title

             <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>              <a href="#<?php echo $post->post_name; ?>"><?php the_title(); ?>                  <?php endwhile; wp_reset_postdata(); ?>             <?php endif; ?>

                        <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>     <div id="<?php echo $post->post_name; ?>">

             <?php $shortcode = do_shortcode('[anything_slides cat='.$post->post_name.']');                 echo apply_filters('my_new_filter',$shortcode); ?>

<?php the_title(); ?>
             <?php echo the_content(); ?>

          <?php endwhile; wp_reset_postdata(); ?>     <?php endif; ?>


title: get_posts() in secondary sidebar messes up content in primary sidebar

text:
I use get_posts() to generate a menu of posts having the current page as the parent. This causes the post_id to be set to the first such post, instead of the original page's post_id. I.e. I want Wordpress to continue as if nothing happened after the query. This is the code I use in sidebar.php:               $args = array(     'posts_per_page'   => -1,     'offset'           => 0,     'category'         => '',     'orderby'          => 'title',     'order'            => 'ASC',     'include'          => '',     'exclude'          => '',     'meta_key'         => '',     'meta_value'       => '',     'post_type'        => $slug,     'post_mime_type'   => '',     'post_parent'      => '',     'post_status'      => 'publish',     'suppress_filters' => true );          $pt=get_the_title();     $posts=get_posts($args);     //loop children custom posts.     if ($posts) {         echo '
';         echo '

'.$m.'';         // Start the Loop.         foreach ($posts as $p) {                  $t=get_the_title($p->ID);             $l=get_permalink($p->ID);             $a='';if ($t==$pt) $a=' class="active"';             echo '

';             echo ''.$t.'';             echo '

';              }   //foreach         echo '

';     }   //if has posts      All available information says get_posts() doesn't affect anything. Well, that's confirmed to be a lie, unless you can spot an error in my code. If I comment out the single line `$posts=get_posts($args);`, main content is OK. I have tried using wp_reset_postdata(), no difference. Thankful for any help by the pros here :)


title: Echo order box (in pages)

text: How can I echo the value of the order box in posts? See photo.![enter image description here](http://i.stack.imgur.com/VdldU.png)


title: Add the ".current-menu-item" class to <a> tag?

text: I am changing `wp_nav_menu()` to make it a listless navigation menu (i.e., no unordered list or list item tags) Normally the menu `<li>` has the `.current- menu-item` class attached to it when active. But is there a way to give it to the anchor instead? `<a class="current-menu-item"></a>` Edit: This is currently what I'm doing to remove the tags... if there's a custom walker solution that would be ideal. I'd prefer not having to resort to using any javascript if possible.               $menuParameters = array(       'container'       => false,       'echo'            => false,       'items_wrap'      => '%3$s',       'depth'           => 0,     );          echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );


title: WooCommerce shop page overwriting my shop intro text above the listings

text: I recently switched to WooCommerce from Jigoshop and upon doing that my shop page now doesn't display the intro text that I had above all my items on the shop page. If I go to my "shop page" in the dashboard it displays my intro text but when I go to the live view after publishing it, it's gone. Why would this be happening? My items for sale are being pulled into the shop page but my custom intro text isn't showing up on the live site anymore even though it's there in the dashboard. I wanted to give an overview on my shopping page with some intro text above the actual shop items. How can I fix this?


title: How do I dynamically populate wp_nav_menu from a custom taxonomy?

text: I know this question has been asked in different forms. But as far as I can tell from searching Google and SE/WP it's never been satisfactorily answered. Let's say I have a taxonomy _clubs_ and a custom post type _person_. On each `taxonomy-club.php` page I display all the _people_ who are members of that _club_. **But** I want to achieve a similar effect in my menus:               wp_nav_menu     |     |--Everyone     |  \     |  |- Mr Verlaine     |  |- Mr Lloyd     |  |- Mr Osterberg      |  |- Mr Williamson         |     |--Snooker Club     |  \      |  |- Mr Osterberg      |  |- Mr Williamson     |     |--Golf Club     |  \     |  |- Mr Verlaine     |  |- Mr Lloyd      If possible, I would like my menus to have the current page highlighting functionality of `wp_nav_menu()`. I've experimented with this:               add_filter('wp_nav_menu_items','add_terms');          function add_terms($items) {     $items .= '<li>' . wp_list_categories( array(         'taxonomy' => 'clubs',          'title_li' => 'Clubs') )           . '</li>';     return $items;     }      but it doesn't populate the submenus with the people's names, and it doesn't have that nav_menu css-class goodness. Must I create a more complicated `<li>` by querying out the posts in each term of the taxonomy, paste that in, and that's my lot? Or extend the built-in walker (will it give me the advantages of wp_nav_menu?) Or something else... Thanks!


title: Are href attributes of a elements filtered on output to add the current path?

text: I have some code that basically looks like this (it's more complicated, but even this example shows what I'm running into):               echo 'TEST';      However, what gets sent to the browser is not `<a href="#">TEST</a>`, but instead `<a href="http://example.com/current-page#">TEST</a>`. Is WordPress filtering this somehow to prepend the current page URL in front of the `#`? It just occurred to me that this code is being called by a shortcode, which I imagine opens up the possibility of it being filtered somehow...


title: Limit the number of child page displaying

text:
I created a code for querying child pages when we're on a parent page and also display brother pages if we are on a child page, and works amazing... now my problem is, I cannot find a parameter like post_per_page that allow me to limit the number of page displaying, so far I need to display 5, but if a 6 is added the style breaks... so at the end of the day I just want to limit the number of view to X number, lets say 5. Take a look at the code
          <?php           $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');           $subpages = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0') ;                if ($children) { ?>
<?php echo $children; ?>
               <?php } else { ?>                  <?php echo $subpages; ?>          <?php } ?>
            Thanks in advance. UPDATE* _*_ I found this solution after a while                <?php $this_page_id=$wp_query->post->ID; ?>        <?php query_posts(array('orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 2, 'post_parent' => $this_page_id, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
<?php the_title(); ?>
             <?php } ?>        <?php wp_reset_query() ?>      I'm able to use the post_per_page function and works like charm!


title: Using custom meta_query with relation not working as expected

text: I am trying to create a query to pull future events only. It was working great until the client requested the ability to add date ranges--so the event will either have a start date only, OR a start date and an end date. I need to build a query that pulls events events that has a start date in the future OR an end date in the future. This does not work as expected and pulls all events; and the order of what's pulled seems random, despite setting orderby to meta_value. Any help would be much appreciated!                   function get_upcoming_events($num) {         $today =  gmdate('Y-m-d', time()-28800);              $args = array(             'meta_key'          => 'event_date',             'order'             => 'ASC',             'orderby'           => 'meta_value',             'post_status'       => 'publish',             'posts_per_page'    => $num,             'post_type'         => 'events',             'meta_query' => array(                 'relation'=>'OR',                 array(                     'key' => 'event_date',                     'type' => 'DATE',                     'value' => $today,                     'compare' => '>='                  ),                 array(                     'key' => 'end_date',                     'type' => 'DATE',                     'value' => $today,                     'compare' => '>='                  )             )         );              if ( isset( $data[ 'taxonomy' ]) ) {             $args[ 'tax_query' ] = array();             $args[ 'tax_query' ][0] = array(                 'field'     => 'slug',                 'taxonomy'  => 'event-type',                 'terms'     => 'general'             );         }         $myquery = new WP_Query( $args );         return $myquery;         }


title: How to add tags to identify custom post types in archives?

text:
The most important thing I would like to add that is missing from my site is colored post type tags for each of my 7 custom post types within the category archives, search archives, and tag archives (which all use the same template file). I was able to manually add colored post type tags to each of the 7 single.php files by adding the following code (this one is for single- articles.php):
Articles
;      I think that what I need for the archive template is for the 7 codes for each post type to be there within the loop, but it needs to be conditional or something depending on which post type is being called. I just don't know what the PHP code is that I need to use to do this. Here is what I have added to the archive template in order to get the custom taxonomies for each custom post type to work:
<?php the_terms( get_the_ID(), 'articles-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'questions-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'videos-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'documentaries-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'ted-talks-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'memes-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'music-archives', ' ', '
' ); ?>
      And here is the code for the tags that appears just after it:
<?php the_tags('
', ' ', '
'); ?>
      So I'm assuming I would need to add similar PHP code as what is used for the taxonomy terms, but I just don't know what it is... Does anyone know?


title: Displaying a variable stored in functions.php inside widget

text: I'm trying to display a variable that is stored inside my functions.php file - for the sake of the question this variable is stored as `$test = 'test';`. When i use `echo $test` inside page.php, header.php or any other file the value is returned however when i try to do the same inside a widget (i'm using a plugin that allows execution of PHP inside a widget) nothing happens. Any ideas as to how i could get around this?


title: Extend Media Library

text: The Media Library in WordPress has "Insert from URL" link to the left. It accepts image URLs. It's not said anywhere but if you paste YouTube URL or `<iframe>` code then it will insert it too. It just won't show the preview like it does with image URLs so you can't tell if the code you typed in is valid or not.   1. I'd like to edit this page and make it show previews of valid WordPress Embeds and of valid `<iframes>`. I want it to just show basic information that the embed code was recognized, is valid and can be inserted. I can write all the AJAX requests to validate URLs but I need help with `wp.media` object. I have no idea how to update that page or replace it with my own page? So far I've found /wp-includes/js/media-editor.js where on line 1054 it says `Called when 'Insert From URL' source is not an image. Example: YouTube url.`.   2. Secondly, once it's already done, I'd like to be able to call something like the following piece of code to open the Media Library with "Insert from URL" page selected and with the code added (for users to modify the existing code). The code (this is a working example of how to bring a window for editing images but I need this for "Insert from URL"):               frame = wp.media({         frame: 'image',         state: 'image-details',         metadata: { 'url': 'some-url' }     });     frame.open();


title: Displaying Gravity Form data on Wordpress page

text: How can I display the data from within a Gravity Form on a Wordpress page? (This may be too detailed, but in case anybody wants details about what I'm trying to do, here they are): I have two Gravity Forms - a pledge form, and a recruit form:   * The recruit form (e.g. www.test.com/recruit) is used to create a referral URL that adds a user-specified code onto the end of the pledge form URL. It also captures the user's email.   * The pledge form (e.g. www.test.com/pledge) is used to capture user information (name, email, etc.), and when a user fills it out with a URL that contains a referral code (e.g. www.test.com/pledge/?referrer=iamthereferralcode), the form also captures that code in a field called "referrer".  I need to display the top 5 referral URLs and their email addresses on a certain page on my Wordpress site. I'd appreciate any insight. Thank you!


title: Editing Admin via Child Theme

text:
The theme I'm using provides an admin page that lets me easily setup jQuery sliders on my homepage, but it limits me to five. Now I'm able to go into the actual theme files and edit these so that the backend asks for 7 slides and the front end displays all 7. No problems there, I know exactly where and what to edit. But... editing the theme is not advisable and child themes are the way to go. However, I can't figure out how to make these changes in the child theme, specifically the backend section that takes in the slide info. I've attempted to use my child theme functions.php page to remove the original hooks that call the function building this part of the page. I was able to do that. In attempting to recreate that function with my changes and then hook it into the page I was unsuccessful. I've attempted to simply overwrite the various pages using my child theme and that didn't work. I've attempted to use the child themes functions.php page to flat out rewrite the function that builds this part of the page, and that didn't work either. I tried a new functions.php in the admin folder of my child theme. Nothing. The original theme has an admin-functions.php page and I tried overwriting that in my child theme and got nothing. This is really my first time using child themes so I don't have a ton of experience with them. It's also my first attempt and tweaking anything on the backend/admin side. I know I'm supposed to ask for code specific help but I don't even know which of my tactics above is most likely to be successful because I've never done anything like this. Tell me which potential solution to focus on and I'll be happy to supply code in that regard. Thanks in advance. **Edit:**   in the theme files I can edit this function in the admin/settings.php page of my theme to change the number of slides.               function cryout_setting_frontslider2_fn() {     global $parabolas;           $items = array("Custom Slides", "Latest Posts", "Random Posts", "Sticky Posts", "Latest Posts from Category" , "Random Posts from Category", "Specific Posts");     $itemsare = array( __("Custom Slides","parabola"), __("Latest Posts","parabola"), __("Random Posts","parabola"),__("Sticky Posts","parabola"), __("Latest Posts from Category","parabola"), __("Random Posts from Category","parabola"), __("Specific Posts","parabola"));     echo " Slides content:  ";     echo "<select id='parabola_slideType' name='parabola_settings[parabola_slideType]'>";     foreach($items as $id=>$item) {         echo "<option value='$item'";         selected($parabolas['parabola_slideType'],$item);         echo ">$itemsare[$id]</option>";     }     echo "</select>";     echo "
".__("Only the slides with a defined image will become active and visible in the live slider.
When using slides from posts, make sure the selected posts have featured images.
Read the FAQs for more info.","parabola")."
";      ?>

                <?php _e('Latest posts will be loaded into the slider.','parabola'); ?>

                <?php _e('Random posts will be loaded into the slider.','parabola'); ?>

                <?php _e('Latest posts from the category you choose will be loaded in the slider.','parabola'); ?>

                <?php _e('Random posts from the category you choose will be loaded into the slider.','parabola'); ?>

                <?php _e('Only sticky posts will be loaded into the slider.','parabola'); ?>

                <?php _e('List the post IDs you want to display (separated by a comma): ','parabola'); ?>                 <input id='parabola_slideSpecific' name='parabola_settings[parabola_slideSpecific]' size='44' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideSpecific'] ) ?>' />

                <?php _e('
 Choose the category: ','parabola'); ?>                 <select id="parabola_slideCateg" name='parabola_settings[parabola_slideCateg]'>                <option value=""><?php echo esc_attr(__('Select Category','parabola')); ?></option>                <?php echo $parabolas["parabola_slideCateg"];                $categories = get_categories();                foreach ($categories as $category) {                     $option = '<option value="'.$category->category_nicename.'" ';                 $option .= selected($parabolas["parabola_slideCateg"], $category->category_nicename, false).' >';                 $option .= $category->cat_name;                 $option .= ' ('.$category->category_count.')';                 $option .= '</option>';                 echo $option;                } ?>                </select>
                <?php _e('Number of posts to show:','parabola'); ?>                <input id='parabola_slideNumber' name='parabola_settings[parabola_slideNumber]' size='3' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideNumber'] ) ?>' />
                <?php           // CHANGE THE '5' BELOW TO '7' FOR 7 SLIDES           for ($i=1;$i<=5;$i++):           // let's generate the slides           ?>

<?php _e("Slide","parabola");?> <?php echo $i; ?>

<?php _e("Image","parabola");?>
                     <input type="text" value="<?php echo esc_url($parabolas['parabola_sliderimg'.$i]); ?>" name="parabola_settings[parabola_sliderimg<?php echo $i; ?>]"                          id="parabola_sliderimg<?php echo $i; ?>" class="slideimages" />                     <?php _e( 'Select / Upload Image', 'parabola' );?>
 <?php _e("Title","parabola");?>
                     <input id='parabola_slidertitle<?php echo $i; ?>' name='parabola_settings[parabola_slidertitle<?php echo $i; ?>]' size='50' type='text'                          value='<?php echo esc_attr( $parabolas['parabola_slidertitle'.$i] ) ?>' />
 <?php _e("Text","parabola");?>
                     <textarea id='parabola_slidertext<?php echo $i; ?>' name='parabola_settings[parabola_slidertext<?php echo $i; ?>]' rows='3' cols='50'                          type='textarea'><?php echo esc_attr($parabolas['parabola_slidertext'.$i]) ?></textarea>
 <?php _e("Link","parabola");?>
                     <input id='parabola_sliderlink<?php echo $i; ?>' name='parabola_settings[parabola_sliderlink<?php echo $i; ?>]' size='50' type='text'                          value='<?php echo esc_url( $parabolas['parabola_sliderlink'.$i] ) ?>' />

                <?php endfor; ?>

      this above function is called in admin/main.php of the theme               function parabola_init_fn(){     register_setting('parabola_settings', 'parabola_settings', 'parabola_settings_validate');          ...          add_settings_field('parabola_frontslider2', __('Slides','parabola') , 'cryout_setting_frontslider2_fn', __FILE__, 'presentation_section');     }      the `parabola_init_fn` function is called higher up on that same page               add_action('admin_init', 'parabola_init_fn' );      as I said before, I was able to add the following to my child theme functions.php               add_action('init','unhook_parabola_init_fn');     add_action('admin_init', 'parabola_init_fn_new' );          function unhook_parabola_init_fn() {         remove_action('admin_init','parabola_init_fn');     }      this would remove the original sections of the backend page that let me customize the theme but would not load the `parabola_init_fn_new` function that was exactly the same as the `parabola_init_fn` function except for the call to `cryout_setting_frontslider2_fn_new`, which contained my edit to get more slider options in the backend, instead of the original `cryout_setting_frontslider2_fn`. I hope that all makes sense, but I doubt it will. **2nd Edit:** In the functions.php of my child theme I tried to break things down a bit to see where the problem was occuring. First I changed my hooks so that instead of just unhooking the one function I was also rehooking it.               add_action('init','unhook_parabola_init_fn');     add_action('admin_init','parabola_init_fn');          function unhook_parabola_init_fn() {         remove_action('admin_init','parabola_init_fn');     }      My thinking was that this would go get the function and the page would load fine and proper, but that's not what happened. The page doesn't load anything, all white screen. So something went wrong, maybe I need to have `parabola_init_fn` in the functions.php so I tried that. Nothing. Same blank page. Finally, when I change the second hook to `parabola_init_fn_new` is when the page loads at all. The editable section of my page is still gone. I have no idea what's happening. **3rd Edit:** Figured it out. There was another function calling `parabola_init_fn`. I had to add a bunch more stuff to my functions.php page in order to make sure this was pointing in the right place, but it's now working. Thanks for all your help guys.


title: single_term_title() running before get_the_title()

text: This is a strange "problem" but I've had this happen on a few installs and I was wondering if anybody could give an explanation on why / how this happens. On a blog category if I code: `<?php echo get_the_title(1).': '.single_term_title(); ?>` Outputted to my screen: `UncategorizedBlog:` On the otherhand, if I do this: `<?php echo get_the_title(1); ?>: <?php single_term_title(); ?>` I get the correct output `Blog: Uncategorized`. I'm not sure if this is a PHP problem or a WordPress or maybe it's something in my code I've messed up along the way. Anyway I was curious as to why it appears that way since I would think order of operations would print the first function first, move onto the concatenation, then proceed to the `single_term_title()` but apparently this is not the case.


title: Exclude featured image from gallery code stops Lightbox from working

text: I was looking for a solution to exclude the featured image/thumbnail in each post, so I found this great piece of code and added it to functions.php. It worked perfectly except for one thing: it renders the Lightbox jquery plugin useless. The difference I see in code is this. With the code:                     Without:                     It seems the filter does something to the post_gallery that makes WP not show the Lightbox part (missing rel="lightbox[]"), but I can't figure out why it does that. Reference code in functions.php from here:               function exclude_thumbnail_from_gallery($null, $attr)     {         if (!$thumbnail_ID = get_post_thumbnail_id())             return $null; // no point carrying on if no thumbnail ID              // temporarily remove the filter, otherwise endless loop!         remove_filter('post_gallery', 'exclude_thumbnail_from_gallery');              // pop in our excluded thumbnail         if (!isset($attr['exclude']) || empty($attr['exclude']))             $attr['exclude'] = array($thumbnail_ID);         elseif (is_array($attr['exclude']))             $attr['exclude'][] = $thumbnail_ID;              // now manually invoke the shortcode handler         $gallery = gallery_shortcode($attr);              // add the filter back         add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);              // return output to the calling instance of gallery_shortcode()         return $gallery;     }     add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);      Thanks a lot in advance! **UPDATE** : I found this http://core.trac.wordpress.org/ticket/14130 it says it adds filter post_gallery_output but I can't figure out what is that I have to modify in the current code to try another solution.


title: How to add pagination to my code?

text:
I just want to ask how can I add pagination here in this code:               <?php if ( get_option('webly_display_media') == 'on' ){ ?>

                                     <?php                                          $args=array(                                             'showposts' => '7',                                             'category__not_in' => get_option('webly_exlcats_media')                                         );                                         query_posts($args);                                     ?>                                     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                                         <?php                                              $width = 140;                                             $height = 72;                                             $titletext = get_the_title();                                             $thumbnail = get_thumbnail($width,$height,'project-image',$titletext,$titletext,true,'Media');                                             $thumb = $thumbnail["thumb"];                                             $et_medialink = get_post_meta($post->ID,'et_medialink',true) ? get_post_meta($post->ID,'et_medialink',true) : '';                                             $et_videolink = get_post_meta($post->ID,'et_videolink',true) ? get_post_meta($post->ID,'et_videolink',true) : '';                                         ?>
                                             <?php if ( $et_medialink <> '' ) { ?>                                                 <a href="<?php echo $et_medialink; ?>">                                             <?php } elseif ( $et_videolink <> '' ) { ?>                                                 <a href="<?php echo $et_videolink; ?>" rel="prettyPhoto[media]" class="et-video" title="<?php echo $titletext; ?>">                                             <?php } else { ?>                                                 <a href="<?php echo $thumbnail["fullpath"]; ?>" rel="prettyPhoto[media]" title="<?php echo $titletext; ?>">                                             <?php } ?>                                                     <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, 'project-image'); ?>
                                       <?php endwhile; ?>                                     <?php endif; wp_reset_query(); ?>

       My posts has a featured video and currently that code displays 5 featured video base on the category. The problem is, I already have 11 posts in that category but the theme can only display 5 posts so I want to have a pagination for that. Can you help me? Here's the development site http://dev.freelanceu.net/mjl/fitnessadventure/. You can see the above code at the bottom of the content, before the footer.


title: How to make search for the custom post type?

text:
i tried to figure this out but i can't until know i have new custom post type of `questions` and i have other post types also like `job listing`, `resumes` etc what i want here to make search for the post type questions only here what i done                           <?php global $app_abbr, $header_search; $header_search = true; ?>                 <?php get_header(); ?>                                    <form action="<?php bloginfo('url'); ?>/" method="get" id="searchform">

                                 <input type="hidden" name="questions_search" value="true" />                                 <input type="hidden" name="post_type" value="questions" />                                               <input type="text" id="search" title="" name="s" class="text" placeholder="<?php _e('All Questions and answers'); ?>" value="<?php if (isset($_GET['s'])) echo get_search_query(); ?>" />                                 <button type="submit" title="<?php _e('Go'); ?>" class="submit"><?php _e('Go'); ?></button>

                          </form>      and the search page                               <?php                     global $wp_query, $query_string;                          $term_heading = '';                     $find_posts_in = '';                          $search = get_search_query();                          if ($search) :                         $term_heading = sprintf( __('Searching  for Questions “%s” '), get_search_query());                     else :                         $term_heading = __('Searching  ');                     endif;                               if (is_array($find_posts_in)) :                         $args = array_merge( $wp_query->query,                             array(                                 'post_type' => 'questions',                                 'post__in' => $find_posts_in                             )                         );                     else :                          $args = array_merge( $wp_query->query,                             array(                                 'post_type' => 'questions'                             )                         );                     endif;                     query_posts( $args );                     ?>


title: onclick open window

text:
I am using AS-PDF plugin in WordPress. In this plugin, For opening new window, I would like to add onclick events in it like that               function as_pdf_link( $strContent ){     global $wp_query;          $strHtml = '
                         post->ID .'"onclick="open(this.href, this.target, 'width=600, height=450, top=200, left=250'); return false;">                                     ' . stripslashes( get_option( 'as_pdf_linktext' ) ) . '
                         ';          return $strContent . $strHtml;      } But It doesn't work. So, please guide me how to do. Thank in advance.


title: Why doesn't flush_rewrite_rules run on plugin activation?

text: I'm trying to flush rewrite rules in a plugin and it isn't working. I have to go to permalinks -> save in the admin panel for the rewrites to flush. Can anyone see why?               class SpektrixPlugin {          public function __construct(){         add_filter('query_vars', array($this, 'add_query_vars'));         add_action('init', array($this, 'add_rewrite_rules'));     }          public function activate() {              flush_rewrite_rules();     }          public function deactivate() {              flush_rewrite_rules();     }          public function add_query_vars($vars) {         $vars[] = "event"; // name of the var as seen in the URL         return $vars;     }          public function add_rewrite_rules() {         $page = get_page_by_title( 'Event' );         add_rewrite_rule( 'whats-on/(.+)/?$' , 'index.php?page_id='.$page->ID.'&event=$matches[1]' , 'top' );     }               }          $SpektrixEvents = new SpektrixPlugin;          register_activation_hook( __FILE__, array($SpektrixEvents, 'activate') );     register_deactivation_hook( __FILE__, array($SpektrixEvents, 'deactivate') );


title: Quote rotator in the sidebar

text: I like to style some post (bold and link) in the post editor (easy and fun) and categorize it as "quote". Then display it based on a CSS in a sidebar, rotating it, like show 1 each 5 second, randomly. Do you know a plugin the just do that ? thanks in advance


title: How to modify/extend/override a core method?

text: This is my first post. In advance, thank you for welcoming me... # Context When you enqueue style, you can output your css link into conditional comments.               global $wp_styles;     wp_enqueue_style("my_styles_ie");     $wp_styles->add_data("my_styles_ie", "conditional", "(lt IE 9) & (!IEMobile)");      It will produce the following code :               <!--[if (lt IE 9) & (!IEMobile)]>         <link rel="stylesheet" href="#" />     <![endif]-->      This is done by the `do_item()` method of the `WP_Styles` class (class.wp_styles.php). # Goal I'd like to add a "anticonditionnal" parameter with the condition value...               $wp_styles->add_data("my_styles_ie", "anticonditional", "(gt IE 8) | (IEMobile)");      to be able to output this ("nested comments"):               <!--[if (gt IE 8) | (IEMobile)]><!-->         <link rel="stylesheet" href="#">     <!--<![endif]-->      I have searched about "how to modify core method" but I didn't find any solution... :( For now, I can do it with a hook but there is no "arguments". Stylesheet and condition are hardcoded...               function antiConditionnal($tag, $handle) {         if('my_styles' == $handle)             $tag = '<!--[if (gt IE 8) | (IEMobile)]><!-->' . "\n" . $tag . '<!--<![endif]-->' . "\n";              return $tag;     }     add_filter( 'style_loader_tag', 'antiConditionnal', 10, 2);      This is mainly for me an opportunity to improve my knowledge and dive deeper into WordPress! Any idea? Thank you... tm


title: Function to get permalink of custom post type archives?

text: Is there a function that will return the permalink to a custom post types archives that is available to use in WordPress? Something like: `get_cpt_permalink("events")` which will return `http://example.com/events/` when `has_archive => true` on it. If not what would I need to home brew my own? I'm thinking I would need to read `$wp_rewrite` and use something along the lines of `$wp_rewrite->get_extra_permastruct('events');`


title: Will A WordPress automatic update harm my website?

text: Recently I got to know that my Wordpress site is automatically updating itself when a new version of Wordpress is available. I know that this automatic feature is available in Wordpress since sometimes back. But I have some questions about this:   1. Can this be risky in any case?    2. Does it matter how we have installed Wordpress? (e.g plugins and security settings)    3. Does Wordpress have a way to recover our website if anything goes wrong?   4. Does WordPress keep any backup when doing the update?


title: Detect category choice for posts with multiple categories

text: On my single template, I wish to show other posts in that category.   Its essential that I use the route they chose, i.e. if they clicked Category 1, then Post A, if Post A is also Categorised as Category 2 and Category 3, I only want to show posts from Category 1 because that is what they originally chose. Is this an option? Is there a way to store some sort of global variable which I can set on my category page, then utilise on my single page?


title: Error while setting role

text: I already got code which can change role basis on post count.               <?php            add_action( 'save_post', 'update_roles' );         function update_roles( $post_id ) {                  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )                 return $post_id;                  // Get the author             $author = wp_get_current_user();                  // Set variables for current user information             $count = count_user_posts( $author->ID );             $current_role = (array) get_user_meta( $author->ID, 'wp_capabilities' );                  get_currentuserinfo();              global $user_level;                  // Do the checks to see if they have the roles and if not update them.             if ( ($user_level != 10) && ( $count > 3 && $count <= 5 ) && ( array_key_exists( 'contributor', $current_role[0] ) ) ) {                 $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'author' );                  } elseif ( ($user_level != 10) && ( $count > 5 && $count <= 9 ) && ( array_key_exists( 'author', $current_role[0] ) ) ) {                      $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'editor' );                  } elseif ($user_level != 10){                      $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'contributor' );                  } return $post_id;              }          ?>      Now I have tested on local environent and it was working but now I dont know why it is giving me error as below.               Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/....../themes/..../inc/functions/user-role.php on line 20          Warning: Cannot modify header information - headers already sent by (output started at /home/....../themes/..../inc/functions/user-role.php) in /home/...../wp-includes/functions.php on line 861      Please help me to solve this.


title: Google Apps login in wordpress

text: I manage a google apps domain with plenty of users; I would like to join Google apps with a Wordpress based intranet app we're creating. Which level of integration could I expect to achieve? Our hope is to create users in wordpress using their google apps email and let them login using their google apps password, so that they don't need to remember two different passwords. How would you suggest we should implement this?


title: Version Control: Entire site or just pieces?

text: I've been using git to track changes in the plugins and themes I've developed for different sites. Each plugin or theme has their own repository in whichever local install of WordPress I happen to be using for that project. This works fine when I'm just working on one solitary plugin or theme. But when I have a local version of an entire site which is a collection of different plugins, themes, WordPress core, etc. Should I be keeping that entire directory under version control? Is there a best practice to always have a collection of repositories for each theme/plugin, or for each client site to have one monolithic repository that includes all the code used in the project (including the latest copy of WordPress via svn.)


title: Why doesn't my WP Meta Query return any results?

text:
Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any results. Is my code incorrect? Any help will be much appreciated..               <?php     if ( get_query_var('paged') ) {     $paged = get_query_var('paged');     } else if ( get_query_var('page') ) {     $paged = get_query_var('page');     } else {     $paged = 1;     }     $args = array(     'post_type' => 'property',     'paged' => $paged     );          if($_GET['beds'] >= 1) {     $args['meta_query'][] = array(     'key' => $_GET['beds'],     'value' => array('pyre_BHK-A','pyre_BHK-B','pyre_BHK-C','pyre_BHK-D','pyre_BHK-E'),     'compare' => 'IN'     );     }          if(($_GET['price-max'] >= 1)&&($_GET['price-min'] >= 1)) {     $args['meta_query'][] = array(     'relation' => 'OR',     array(     'key' => 'pyre_price',     'value' => array($_GET['price-min'],$_GET['price-max']),     'compare' => 'BETWEEN',     'type' => 'numeric'     ),     array(     'key' => 'pyre_pricem',     'value' => array($_GET['price-min'],$_GET['price-max']),     'compare' => 'BETWEEN',     'type' => 'numeric'     )     );     }          query_posts($args);     if(have_posts()):     ?>          <?php     while(have_posts()): the_post();     ?>               <?php get_template_part( 'property-listing' );           // Navigation bar (property-listing.php) ?>          <?php endwhile; ?>          <?php else: ?>
<?php echo of_get_option('search_results_none_title', 'No properties were found which match your search criteria.'); ?>

<?php echo of_get_option('search_results_none_content', 'Try broadening your search to find more results.'); ?>
     <?php endif; ?>


title: Single loop with dual content area

text: Is there a way to implement a single loop with dual content area. **E.g. A single loop having 2 of** `<?php the_content(); ?>` **Dinstinguished as shown bellow with video and write-up respectively**               <?php the_content('video'); ?>          <?php the_content('write-up'); ?>


title: How to solve this without flushing the rewrite rules for each post query the visitor triggers?

text: Actually I have the problem that I provide a menu link (predefined in theme) to the latest post of a specific custom post type. I achieve this by the following function …               function get_latest_magazine_issue_url() {         global $wpdb;         $query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type='magazine_issue' AND post_status='publish' ORDER BY post_date DESC LIMIT 1;";         $result = $wpdb->get_results($query);         if(is_object($result[0])) { return get_permalink($result[0]->ID); }          else { return ''; };     }      … fine til that point – but I recognized, that when I clicked on that link after adding a new cpt post, the link will still grab the post which was the latest when I implemented this link via widget. Is there any way to get around this without a flush_rewrite_rules() call? I wouldn't like to flush that way cause the codex says: http://codex.wordpress.org/Function_Reference/flush_rewrite_rules


title: How to get the number of posts in a selected category?

text: I would like to show the number of posts on the category page. How is it possible? I tried to find a solution but no luck.. Thank you!


title: why do drafts return as part of wp_query?

text: I have some code as plugin, which I call via AJAX from a page one the site. It gets two drop-down values and uses them in tax_query to fetch some posts. Question: why do **drafts** return amongst results by default? I need to uncomment `'post_status' => 'publish'` to prevent this from happening. User is not logged in, and the doc says > "Default value is 'publish', but if the user is logged in, 'private' is > added. And if the query is run in an admin context, protected statuses are > added too. By default protected statuses are 'future', 'draft' and > 'pending'." Does this mean that drafts considered " _public_ " somehow? These are regular posts, no custom post type stuff here. Or is it tax_query overriding the default behaviour somehow? I'm puzzled. Here is the code of query parameters:                 $args = array(         'posts_per_page' => 5,         //'post_status' => 'publish',         'tax_query' => array(           'relation' => 'AND',           array(             'taxonomy' => 'height_category',             'field' => 'slug',             'terms' => array( $_POST['height'] )           ),           array(             'taxonomy' => 'age_category',             'field' => 'slug',             'terms' => array( $_POST['age'] )           )         )       );


title: Password Protected Directory Link Shows Maintenance Mode Page

text: In my WordPress installed directory, I have placed a directory named "Projects". My WordPress site is in maintenance mode with Maintenance Mode Plugin Installed on it. I password protected my "Projects" directory from cPanel, but instead of asking username & password it shows maintenance mode page. Any idea ?


title: how to publish a feed of posts with a certain custom field value?

text: In addition to the normal feed that wordpress produces, i need to publish an additional feed of posts that have a certain custom field value. I'm a bit lost on where to start. Any tip?


title: Why doesn't my Table get created?

text: I am working on creating a table in the DB for a plugin but cannot figure out why the table is not being created. Here's my code:               global $ds_swoons_db_version;     $ds_swoons_db_version = '1.0';          function ds_swoons_install(){     global $wpdb;          $table_name = $wpdb->prefix . "ds_entry_swoons";              if( $wpdb->get_var("show tables like '$table_name'") != $table_name ):         $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " (                 id mediumint(9) NOT NULL AUTO_INCREMENT,                 post_id int(9) NOT NULL,                 user_id (9) NOT NULL,                 swoon_status int(1),                 UNIQUE KEY id (id)                 );";         require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         //make the query         dbDelta($sql);         //add db verison number         add_option('ds_swoons_db_version', $ds_swoons_db_version);     endif;          }//end ds_swoons_install          register_activation_hook( __FILE__, 'ds_swoons_install');      I tried to echo the error but get an unexpected output error - probably due to headers being sent already. This is all the code I have so far - just wanted to see if I could create the table before moving on to anything else. Thanx in advance! EDIT ---------------------------------------------------- I figured it out - I did not have the data type declaration for user_id so it never created the table. I changed it and it worked :)


title: Where is the source of the media items filter

text: I couldn't find the source in the php files. What is generating the select drop-down for the attachment filters in the media library? ![media items filter](http://i.stack.imgur.com/siVpq.png)


title: Twenty Eleven: Home Page, View full post of most recent post & Summary of the rest

text: I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts. For Example (Post #5 being the newest & Post #1 being the oldest): Post #5 (Full Article) Post #4 (Summary) Post #3 (Summary) Post #2 (Summary) Post #1 (Summary) <-- Next Any ideas? Please help!


title: Custom posts type for individual pages?

text: I am trying to make a wordpress site with an idiot-proof backend CMS. I have built several relatively small wordpress sites, but now have moved on to a larger project and want to do it _right_. There will be several (maybe as much as 10+) pages each with unique structures and elements (different numbers of pictures, and text-content areas). There will be maybe a couple dozen other pages with more standard layouts (just some text into a template). Ideally, I would want the "edit page" area of each 'unique' page to have its own unique set-up. For Example, heres a few sample pages: Home page   * List item   * 2 sections of text   * 6 photos with captions (captions are split in 2 sections each for 2 fonts and a line break) About page   * 2 images (no captions)   * 1 main text section   * 1 video Videos page   * 2 text sections   * 1 picture   * any number of videos Now its pretty clear to me that for the videos page, I should create a custom- post-type video, where the user can put in the url for a YouTube video, some descriptive text etc... and then pull all of those video posts into my videos page. What is unclear to me is whether I should make a 'homepage' custom-post-type with only one post (the homepage) and do the same thing for other pages with unique elements/layouts. I hope this is clear enough, I can elaborate more or create some images of what I have in mind, but this seems to be getting rather lengthy.


title: How do I urlencode() the blog description?

text: I have a series of share buttons, each one using a short URL (using Ozh's Yourls plugin) and a page title (as found on urlencoding of the_title() doesn't work?) and some require a description. How do I put the blog description, encoded correctly, into my URL?


title: How to redirect unattached image attachments

text: I'm currently redirecting all attachment images to their parent post with the following function:               function attachment_redirect() {         global $post;         if ( is_attachment() && isset( $post->post_parent ) && is_numeric( $post->post_parent ) && ( $post->post_parent != 0 ) ) {             wp_redirect( get_permalink( $post->post_parent ), 301 );             exit();         }     }     add_action( 'template_redirect', 'attachment_redirect' );      How can I redirect all images that have been uploaded to the media library but remain 'unattached'? My aim is to redirect these images to the homepage.


title: How to tell if the user is an admin?

text: I need to show some info only to admins visiting a page, so I need a conditional tag to identify them. So far I have found:               <?php if ( current_user_can('manage_options') ): ?>      is this the correct function?


title: Year based WP Query

text: I am am having a strange issue, trying to get year based posts in wp_query, when i do directly, 'year' => '2014' it works fine, but i have the year stored in a variable, $year, then i do 'year' => $year; it shows all posts, did echo of $year, shows 2014 here is the complete code I am using..               global $paged;     if( get_query_var( 'paged' ) )         $my_page = get_query_var( 'paged' );     else {         if( get_query_var( 'page' ) )             $my_page = get_query_var( 'page' );         else             $my_page = 1;         set_query_var( 'paged', $my_page );         $paged = $my_page;     }          $setyear = '2014';          $args = array(         'post_type' => 'news_posts',         'year'  => $setyear,         'tax_query' => array(             array(                 'taxonomy' => 'news_category',                 'field' => 'slug',                 'terms' => 'press-releases'             )         ),         'paged' => $my_page     );      Thanks.


title: get next next post in single.php

text: I really need your help. in my single.php I had to get the next post in the same category (which i already have by: $in_same_cat = true; $excluded_categories = ''; $previous = false; $next_post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);) now I need the **next next** post and also in the opposite direction **previous previous** post thanx


title: Translate third party plugin and save translation files in custom theme

text: I'm using Codestyling Localization and I want to translate a plugin and I want the translation files to be saved in the translation directory in the theme I'm building and not in the plugins directory. Is this possible? I have tried `load_plugin_textdomain` and `load_textdomain` but that doesn't seem to work.               // Add localization     load_theme_textdomain( 'my_theme', $translation_directory );          $domain = 'other_plugin';     $locale = apply_filters('plugin_locale', get_locale(), $domain);     load_textdomain( $domain, WP_LANG_DIR.'/'.$domain.'/languages/'.$domain.'-'.$locale.'.mo');     load_plugin_textdomain( $domain, FALSE, $translation_directory );


title: What do I need jQuery for?

text: What do you think of killing jQuery in the public facing WP site? Isn't it useless and making for slower page loading? What's the best way to get rid of it?


title: Files empty after moving with FTP

text: I have a strange bug within my Wordpress theme. After I copy normal files from my local machine (whatever file, functions.php, styles.css or any other) the file gets empty on the server, with no content and I can see the size of 0mb. On the backend, wp-admin works normally, I have previousely received some caching error but that its. Any ideas? P.s. I am using WP 3.1


title: How to mask url of a specific page without affecting seo

text: What I'm looking to do is exactly this and/or this. What's holding me back is my fear of losing all the SEO traffic my posts at site.com/blog/post have already acquired. Would implementing this fix negatively affect the page rankings of my posts and if so, by how much?


title: Why is my AJAX call not working?

text:
I have similar code working from within a theme's functions.php file, but I want to move it to a plugin. I've assembled the following but for some reason, this method is having trouble at the AJAX call and always returns zero. The intention here is that the form will be on the front-end and usable by either logged-in or NOT logged-in users. Here's my plugin code:               /*     Plugin Name: AAA Hello World     Plugin URI: http://helloworld.com     Description: AJAX response to form submission     Version: 1.0     Author: John Doe     Author URI: http://helloworld.com     */          class RespondToMyClicks {            function __construct() {              add_action( 'wp_enqueue_scripts', array( &$this, 'click_response_styles' ) );         add_action( 'wp_enqueue_scripts', array( &$this, 'click_response_scripts' ) );              if( is_admin() ) {           add_action( 'wp_ajax_the_ajax_hook', array( &$this, 'process_clicky_form' ) );           add_action( 'wp_ajax_nopriv_the_ajax_hook', array( &$this, 'process_clicky_form' ) );         }              add_shortcode( 'click_response_form', array( &$this, 'click_response_form' ) );            }            public function click_response_styles() {              wp_register_style( 'respond-to-my-clicks', plugins_url( dirname( plugin_basename( __FILE__ ) ) . '/styles.css' ) );         wp_enqueue_style( 'respond-to-my-clicks' );            }            public function click_response_scripts() {              wp_enqueue_script( 'respond-to-my-clicks', plugin_dir_url( __FILE__ ) . 'ajax.js', array( 'jquery' ) );         wp_localize_script( 'respond-to-my-clicks', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );            }            public function process_clicky_form() {         if( !empty( $_POST ) && wp_verify_nonce( $_POST['post_filtration'], 'post_filter_action' ) ) {           echo "Hello World";           die();         }       }            public function click_response_form() {         $the_form = '<form id="theForm" method="post" action="">' .          wp_nonce_field( 'post_filter_action', 'post_filtration' ) .          '<input name="action" type="hidden" value="the_ajax_hook" />             <input type="checkbox" name="change_me"  value="" onChange="submit_me();" /> Click me for a response         </form>

';         return $the_form;       }          }          new RespondToMyClicks();      And here's my Javascript file code:                   function submit_me() {                  jQuery("#response_area").fadeOut("slow");                  jQuery.post(the_ajax_script.ajaxurl,              jQuery("#theForm").serialize(),                 function(response_from_the_action_function){                     jQuery("#response_area").html(response_from_the_action_function).fadeIn("fast");                 }             )              }      I've been looking at this too long and have tried different variations of code so hopefully someone can point out the obvious cuz I'm just plain missing it. Thanks!


title: Template for custom post type shows all posts instead of just one

text:
I wrote a simple plugin to create a custom post type named "people":               add_action( 'init', 'create_person' );          function create_person() {         register_post_type( 'people',             array(                 'labels' => array(                     'name' => 'People',                     'singular_name' => 'Person',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Person',                     'edit' => 'Edit',                     'edit_item' => 'Edit Person',                     'new_item' => 'New Person',                     'view' => 'View',                     'view_item' => 'View Person',                     'search_items' => 'Search People',                     'not_found' => 'No person found',                     'not_found_in_trash' => 'No people found in trash',                     'parent' => 'Parent Person'                 ),                      'public' => true,                 'menu_position' => null,                 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),                 'taxonomies' => array( '' ),                 'menu_icon' => plugins_url( 'images/people_icon.png', __FILE__ ),                 'publicly_queryable' => true,                 'show_ui' => true,                  'show_in_menu' => true,                  'query_var' => true,                 'rewrite' => array( 'slug' => 'people','with_front' => FALSE),                 'capability_type' => 'post',                 'hierarchical' => false,                 'has_archive' => true             )         );     }      And added a template called single-person.php to display the custom post type. This filter is in the same file as the code above:               add_filter( 'template_include', 'include_template_people', 1 );          function include_template_people( $template_path ) {         if ( get_post_type() == 'people' ) {             if ( is_single() ) {                 // checks if the file exists in the theme first,                 // otherwise serve the file from the plugin                 if ( $theme_file = locate_template( array ( 'single-people.php' ) ) ) {                     $template_path = $theme_file;                 } else {                     $template_path = plugin_dir_path( __FILE__ ) . '/single-people.php';                 }             }         }         return $template_path;     }      Then there is the actual template here:               <?php      /*Template Name: New Template      */          get_header(); ?>

         <?php         $mypost = array( 'post_type' => 'people', );         $loop = new WP_Query( $mypost );         ?>         <?php while ( $loop->have_posts() ) : $loop->the_post();?>             <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

                             <?php the_post_thumbnail( array( 300, 300 ) ); ?>

<?php the_title(); ?>

                             <?php echo get_the_term_list( $id, 'roles', '', ', ', '' ); ?>

<?php the_content(); ?>

              <?php endwhile; ?>

     <?php wp_reset_query(); ?>     <?php get_footer(); ?>      UPDATED: I changed the question a bit. I removed a piece of code that I had added. The problem with this template is that when I go to the URL:               mysite.com/people/firstname-lastname      I expect to only get the post of type 'people' which has the slug "firstname- lastname". Instead, all the posts of type 'people' show up on the page. How can I change this so that only the single 'post' is displayed?


title: wp_get_attachment_image_src() does not return what I want

text: I got this annoying issue I can't solve :               if( $meta1 = '' && $meta2 = '' ) {      $image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function());     echo  $image_attributes[0];     } elseif(  $meta1 != '' ) {          echo $meta1;      } elseif ( $meta2  != '' ){         $image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function() );         echo $image_attributes[0];     } else {         echo "ko";     }      when I print_r `my_own_size_function()` I get an array like this :               Array     (          [0] => 600          [1] => 400     )      But when I print_r `$image_attributes`I get another result :               Array     (         [0] => http://localhost/wordpress/wp-content/uploads/2013/07/my_image.jpg         [1] => 200         [2] => 150         [3] =>      )      Any idea of what can be the reason for this? Thanks in advance.


title: How to get all the terms of a post

text: Here is my code so far:               $terms = wp_get_post_terms($event->ID, 'speakers', array("fields" => "all"));     print_r($terms);      It displays this:               Array (         [0] => stdClass Object (                [term_id] => 64                [name] => Apostle Dr. N Suppaya                [slug] => apostle-dr-n-suppaya                [term_group] => 0                [term_taxonomy_id] => 64                [taxonomy] => speakers               [description] => Apostle Dr. N Suppaya, God called him to the ministry, anointed him and told him to bring love, joy and peace of Jesus Christ to the world. In 1986, Apostle Suppaya received the Apostolic calling from God when God told him to build a Church which will be an instrument in building the Kingdom of God through evangelism and missions to the unsaved. This gave the birth to Jesus Lives Church. God has been blessing him with great miracles to testify the glory of God through his ministerial exposures.                [parent] => 0                [count] => 2 )              [1] => stdClass Object (                [term_id] => 61                [name] => Pastor Lynette Teo                [slug] => ps-lynette-teo               [term_group] => 0               [term_taxonomy_id] => 61               [taxonomy] => speakers               [description] => Pastor Lynette Teo graduated from RHEMA Bible Training Centre Singapore is married to Kevin and both are currently instructors at RBTCS, with a strong passion to teach and equip believers in Singapore and Asia in order to further God’s purposes and plans in advancing His Kingdom. They have also ministered in bible schools and churches in various parts of Asia including Malaysia, Indonesia, Thailand and Myanmar. They serve as leaders in their local church and are actively involved in areas of mentoring and discipleship. Lynette also serves in the prayer as well as worship ministries.                   [parent] => 0                [count] => 1         )      )       How can I echo just name and description?