Add admin script to several post types

I have found several tutorials how to add script to certain post type.like               add_action( 'admin_print_scripts-post-new.php', 'banner_admin_script', 11 );     add_action( 'admin_print_scripts-post.php', 'banner_admin_script', 11 );     function banner_admin_script() {     global $post_type;     if( $post_type == 'members' )       wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true); //"TRUE"-ADDS JS TO FOOTER       }      Now how can add this script to multiple post types?May be like this `if( $post_type == array('members','post','testimonial') )`.


Style file inclusion

I am trying to include a `flexslider.css` file with this code:               wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );     if( is_page( 'home' ) ) {         wp_enqueue_style( 'flexslider' );     }      but it is not working this way, any idea why? trying to solve this one for a whole day.


Yearly Archive Page?

Is it possible to have Wordpress automatically create yearly archive pages; simarily to how it creates monthly archive pages. For example: blog/2013/07/ shows all the posts form July, 2013 and like to be able to put in blog/2013/ to get all the posts from that year.


What are the best practices for using a caching plugin on a shared host?

I've launched quite a big site the other day and I'd like to incorporate a caching plugin. The setup is single-site with some Buddypress features mixed in (for user registration, maps with gpress, having a profile) running on a shared host. My questions are:   1\. Which plugin you consider best for caching given this setup and why (if possible)?   2\. What are the best practices and steps I should take/consider during the setup to make sure all is working?   3\. Are _**`transients`**_ which I've added myself can still be used or should I remove them and leave the plugin do it's thing? will they clash if not removed? Thanks! ADDITION: 'Power' plan on http://www.inmotionhosting.com/hostingplans.html


What's the best approach for showing posts by A->Z order?

I've just launched a site that has a RESOURCES section in it, listing of school, documents etc. now the client asks to add an 'Alphabetical Sorter' that will enable the users to see in each specific category the post/resources according to their first letter. This wouldn't be to hard (theoretically), the problems are that those are custom-post-types with nested categories and I already manipulate the request (on the `request` filter) to get what I want and not a 404. The structure is `domain.com/resources/parent-category/child-category/post- name` and I'd like to have pretty permalink look so `domain.com/resources/parent-category/child-category/A-Z` and not using a `index=A-Z`. This should also work (show the correct posts in a-z order) when the user deletes part of the url, i.e. `domain.com/resources/parent-category/A-Z` or `domain.com/resources/A-Z`. What would be the best approach for that, considering we can't go back and add 'category per letter', taxonomy, custom field etc.? Is there a way to maybe hook into the raw SQL and edit it like here http://wordpress.org/support/topic/first-letter-posts? Thanks!


Sorting for each custom taxonomy

I have a custom post type called Baseball Players which contains teams, positions, and a league taxonomy. A team consists of the team name, logo, description, and coach. A position just consists of the name. A league consists of a name, logo, description. So when you create a new Baseball player custom post type you can assign the team, position, and league for the player. Now, I'm looking for a way to customize the order players are displayed in each taxonomy. For example, when you view players by team name the order is completely different for each team. It is not by position, league or a specific field. The same is true for position and league. When you view players by league the order of players is different for each league. I don't believe we can implement this through the menu_order field because you would need multiple menu_order fields (one for each team, position, and league for each player). Though this might be the only solution. Is there a way to handle this unique ordering for each term in the taxonomy? Additionally, is there a way to add multiple custom fields for a taxonomy (ex: team, which contains a team name, logo, description, and coach)? Let me know if you need me to further explain. Any help is appreciated. Thanks!


Problem using Press-this book marklet

When I use the bookmarklet button to test bookmarking . Only some URLs might able to display the post page.For other URLs it is just showing an error:               404. The requested page was not found.      I have deactivated all the plugins .But problem not solved .I have changed the theme though . Do any body have Idea on solving this problem? I am not sure how to solve the problem .I copied the screen shots of error here . ![alt text](http://i.stack.imgur.com/kuTcU.png)


Conflicting post edit options under dashboard

My dashboard( It is multisite Installation ) section for pages and posts conflicts with options when there are morethan 5 data fields . For example : I have these things under my Posts section in dashbpard : **Title Author Categories Tags Comments Date Forum-Linked Featured** Because of these many fields these options conflicts each other like shown in the screen shot : **Edit | Quick Edit | Trash | Preview | Purge from Page Cache** ![alt text](http://i.stack.imgur.com/ANHdh.png) It is because of the increased fields like **forum-linked ,featured etc**. Some times when I install any other related plugins .The number of data fields increases and it becomes more ugly with the editing options . Could any one suggest me a good Idea to fix this ?


Get meta data from image

How can I get the description of the image?               $album_id = get_the_id();     $photos = $wpdb->get_results(         "select * from wp_postmeta where post_id = '"         . $album_id         . "' AND meta_key = 'gallery_ph' order by meta_id desc"     );      This is the result of the SQL query:               Array (           [0] => stdClass Object (             [meta_id] => 887             [post_id] => 604             [meta_key] => gallery_ph             [meta_value] => http://xxx/wp-content/uploads/2013/03/foto_03_copy200.jpg         )     )


Problem using role_has_cap hook

I'm trying to filter a capability check in order to work around the lack of filters to customize the user edit page in the admin area. But I can't seem to add filters to a hook, and I'm sure I'm missing something basic here. The hook in question is `role_has_cap`, located at line 343 of `wp- includes/capabilities.php`. It reads:               $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );      I'm trying to test my filter by adding this to my `functions.php`:               add_filter('role_has_cap', 'my_role_has_cap_filter', 10, 3);     function my_role_has_cap_filter($var_one, $var_two, $var_three) {         print_r($var_one);         print_r($var_two);         print_r($var_three);     }      But absolutely nothing happens. Even if I add the filter with less parameters than my function requires (which, in my limited knowledge, should trigger a PHP error) I'm completely ignored by WordPress. What I'm actually trying to achieve is returning false to a `current_user_can( 'edit_posts' )` or `current_user_can( 'edit_pages' )` when viewing `user- edit.php` on the admin area, **without actually removing those capabilities** , but the fact that a filter is not applying seems to me more relevant that my ultimate goal.


If option: show this. Else show nothing

First, I have to admit I'm not entirely sure on how to explain this best. Currently I have this in my `header.php`:               <?php if ( is_home() OR is_front_page() ): ?>       <meta name="description" content="<?php $options = get_option( 'schema_theme_options' ); echo $options['metadescription']; ?>">     <?php endif; ?>      Would it be possible to hide the remaining               <meta name="description" content="">      if no option availabe?


Automatically Add Caption in image

I want to automatically add caption for each picture appears in the name of the image or the alternative text example Caption add automatic ![example](http://i.stack.imgur.com/piYwF.png)


Displaying a WooCommerce product via PHP

Having a hard time composing a searchable query, so I apologize in advance if this has been covered. I know you can add WooCommerce products to a page or post via short code, but I have one section of my site where it's displaying from theme settings and PHP template only. So my question is, how can I display a product on this section via PHP?


How can I clear the theme mod settings?

Ideally I am looking to add a button to the theme customizer that allows the theme to reset to default settings, although that may be asking for too much in one question so I am wonder if anyone knows how to clear the theme_mod settings so it reverts back to the stylesheet and not the overrides? I created many custmization settings in my theme and after testing them my theme is looking a little funky and I figure it is pretty much mandatory that I have a button to reset the theme to default settings. Does anyone have any experience they could share with me?


Using MathJax in text

I have installed a Mathjax plugin on my local wordpress installation, and the plugin works fine. However, I can't get it to show Latex in-text; it creates an own line for every latex formula. I end up with pages like this (this is an extreme example to get my point across better :)): ![Mathjax](http://i.stack.imgur.com/e6EFS.png) How can I make it work to show Latex in-text? I've tried multiple plugins and they all seem to have this issue, with no option to resolve this.


Create ghost page

I want to create the ghost page `/foo/` so that it appears in the list of pages, but is unclickable and has no content. An example use of this is that in my menu it displays the pagename `foo` and when you hover it, it displays the subpages (which are "real" pages) `bar` and `baz`. The URLs of them would be `/foo/bar/` and `/foo/baz/`. I figured I could simply remove the `<a>` tags of `foo` in Javascript and put a redirect in the `/foo/` page. but that doesn't feel right. What would be an elegant/serverside solution for this problem?


When viewing single parent post, display list of children

I have a Custom Post Type called `glossary`. I set up `parent` posts called "A", "B", etc. The glossary terms themselves are then set with the appropriate initial as their parent post. So, for example, "abdomen" has the "A" post set as its parent and "protein-skimmer" has the "P" post as its parent. I now have a list of these initials,               A     B      When clicking on these links, I'm taken to a view which displays the individual "A" or "B" post. What I'd like to see instead is "A" as a header, then a list of all of its children posts. What's the most effective way to do this? Thanks in advance,


Use of caller_ get_ posts

For what purpose following parameter is used > `caller_get_posts`


Post archives link yields a 404 Not Found

I'm writing my own WordPress theme and I'm having problems with the archive page. My archive link yields a _404 Not Found_. I get this link from `get_post_type_archive_link("post")` and it just adds `/archives` to the base URL of my website. My permalink structure is set to _Post name_ and I have clicked _Save changes_ to make sure that any pending `.htaccess` changes were saved. Category links work fine. Here's a list of PHP files in my theme root:   * 404.php   * front-page.php   * functions.php   * index.php   * pagebottom.php   * pagetop.php   * single.php   * taxonomy.php Any idea why the archive link isn't working?


Change the actual (or viewable) Wordpress directory structure

I like the simplicity of wordpress and all it has to offer, but for security purposes I would like to change the actual (or viewable) directory structure of my site. The install has a set of files that everybody who's familiar with wordpress will know about. I have read about some security measures some where that suggests changing the file/directory structure of a wordpress site to increase the level of security. This would prevent someone from knowing right away if a site wordpress based or not. I have no idea how to do this, but I think using the htaccess might be a solution. Im also concerned about future updates and is there a way to change the actual (or viewable) file structure without effecting updates. I would appreciate some advice on this. Thanks for any help on the matter!


Access $_POST data after redirect

How can I access `$_POST` data after a page redirect? I guess there is some way to tell WordPress to pass all `$_POST` data to the redirected address, like it does with `$_GET` data, using Rewrite Rules, but how?


Woocommerce: Set thumbnail detail (clipping area)

I am using the german Wordpress 3.5.1–de_DE with Woocommerce 2.0.8 and the Woothemes Mystile Theme 1.2.8. I have a big picture for a product (Jellyfish.jpg) and want to use a specific area of that big picture as a thumbnail, because Wordpress/Woocommerce automatically chooses a not useful part of the image. So I used the Wordpress crop tool in Edit Image under Media to generate a 150x150 thumbnail. This sucessfully generates a thumbnail (like Jellyfish-e1367238219134-150x150.jpg) but WP/Woocommerce uses another image (Jellyfish-150x150.jpg). On my FTP I found the following files in /wordpress/wp-content/uploads/ > 012 KB 0666 29.04.2013 14:56 Jellyfish-150x112.jpg   >  015 KB 0666 29.04.2013 14:56 Jellyfish-150x150.jpg   >  026 KB 0666 29.04.2013 14:56 Jellyfish-300x225.jpg   >  082 KB 0666 29.04.2013 14:11 Jellyfish-787x300.jpg   >  009 KB 0666 29.04.2013 14:56 Jellyfish-90x67.jpg   >  017 KB 0666 29.04.2013 14:23 Jellyfish-e1367238219134-150x150.jpg   >  016 KB 0666 29.04.2013 14:58 Jellyfish-e1367240287874-150x150.jpg   >  758 KB 0666 29.04.2013 13:34 Jellyfish.jpg I searched in the template and the plugin but it seems like they simple just use the_post_thumbnail and output the Jellyfish-150x150.jpg image (which is the useless autogenerated thumbnail). Am I doing something wrong? What is the Jellyfish-e1367238219134-150x150.jpg image for? How can I choose which part of the image I want to show as a thumbnail?


How to get posts in different language from WPML Plugin

i'm using Thermal-Api plugin in order to define a REST WS to get posts in JSON format. My Client uses WPML to translate posts and i need to pass to WP_Query the language set in front-end side. Is there a particular parameter to pass to WP_Query to select only the post in that language or is there a way to change dynamically "ICL_LANGUAGE_CODE" in order to retrieve what i need?? Thanks!!


Remove Custom Taxonomy Slug from Permalink

I have a registered custom taxonomy called articles to my posts. So if I have a term called reviews, the link to my custom taxonomy reviews archive would be www.mysite.com/articles/reviews/ . I would prefer it to be www.mysite.com/reviews/ . If that can be done, I would also like to remove the default category slug from the permalink too.


How to check all items in a loop have post thumbnail?

Currently I have the following loop:               <?php     $shows_sales = get_posts(array(         'post_type' => 'show_sale',         'post_status' => 'publish',         'posts_per_page' => 3,     ));     $done_image = false;     ?>
         <?php foreach ($shows_sales as $post) : setup_postdata($post) ?>             <?php if (!$done_image && (has_post_thumbnail())) : ?>
                     <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('homepage'); ?>                     <?php $done_image = true; ?>
                <?php else : ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
                <?php endif; ?>         <?php endforeach; ?>         <?php wp_reset_query(); ?>
      It will show one 'active' list item if post contains featured image, others just show the title in a normal list item. What I need to add is a check that if none of the posts have a feature image, then insert a list item at the top of the unordered list. I'm can't get my head around how to say ' _if none have post thumbnail then show this else do the above_ ' Any help would be greatly appreciated!


Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work

I am using ACF as related posts. I have the following code.               <?php $post_objects = get_field('repeater_related_items');     if( $post_objects ): ?>
         <?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>             <?php setup_postdata($post); ?>
                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                 <?php the_field('repeater_related_items'); ?>
         <?php endforeach;?>
     <?php wp_reset_postdata(); ?>       <?php endif;?>     <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Main Sidebar') ) : endif; ?>      The problem is that when I add this to sidebar other widget doesn't work.


How to fetch only media that was already attached to a post/page?

Situation: my client has this simple gallery built with WP_Query showing the latest media added to the site:               $cola = new WP_Query(         array(         'post_type' => 'attachment',         'post_status' => 'inherit',         'posts_per_page' => 15,         'post_mime_type' => 'image/jpeg',         'orderby' => 'date'         ));      that's working perfect. Except for now we're using AdRotate and want to display ads on the website, but we don't want these ads to be added to the query above. A simple solution for this would be to only fetch media that is attached to a post/page, since ads never get attached to anything. This would be achievable by using `post_parent: array(_of_all_post_ids)` \- except that we already have about 4k posts now, so this is definitely not a good approach. Any ideas how to go about that? _Note: my client is not a techie so this is why i'm ruling out using FTP to use the banner folder AdRotate creates on wp-content. For their planned use, the media gallery would be perfect for the ads._


Wordpress custom field being lost on wp_update_post, with a twist

I'm using wp_update_post to programmatically add a title and tags to posts from the front end. I'm running into a hair-tearing issue with custom fields in the process: one of the two custom fields that are created and populated when the post is initially created has its value deleted, while the other is perfectly fine. This is the part of the code I use to create the post in the first place:               // Set the post ID so that we know the post was created successfully     $post_id = wp_insert_post(         array(             'comment_status'=>  'closed',             'ping_status'   =>  'closed',             'post_author'   =>  $author_id,             'post_name'     =>  $slug,             'post_status'   =>  'publish',             'post_type'     =>  'custom'         )     );          // If the post was created properly     if($post_id) {              // Add meta/custom field data to post         add_post_meta($post_id, 'custom_random_id', $randomId);         add_post_meta($post_id, 'viewcount', '1');      Then, this is the code I use to update the title and tags:               // Continue if untampered     if($new_hashed_value == $_POST['hash']) {              $updatePost = array();         $updatePost['ID'] = $post_id;         $updatePost['post_title'] = $title;         $updatePost['tags_input'] = $tags;              if(wp_update_post($updatePost)) {                  totallyUnrelatedStuff();         }      I understand from other posts that wp_update_post may delete values - but in this case, the custom field ' **custom_random_id** ' is always intact, and ' **viewcount** ' always has its value deleted. I've tried altering it so that it goes:               if(wp_update_post($updatePost)) {                  update_post_meta($post_id, 'viewcount', '1');         }      or even:               if(wp_update_post($updatePost)) {             delete_post_meta($post_id, 'viewcount');                                                 add_post_meta($post_id, 'viewcount', '1');         }      But the **viewcount** field's value continues to be erased. Furthermore, just to throw another wrench at me,               if(wp_update_post($updatePost)) {             delete_post_meta($post_id, 'viewcount');                                                 add_post_meta($post_id, 'new_field', 'new_value');         }      works perfectly. Would anyone know what's going on? Thanks!


Override WordPress Widget CSS Classes?

I'm attempting to style lists in the sidebar (you know, `<ul><li>`) and I'm curious how to also make widgets adopt this class. Each widget seems to have its own class assigned to it by WordPress' defaults - is there a way to override this?


permalink structure for single-{post-type}.php in wordpress

I have tried many ways to display my custom post type as `single-{post-type}` and finally it works nicely once i used:               'rewrite'=> false,      before that, i used               'rewrite' => array( 'slug' => 'custom-post-type' )      but never works for me. Don't know where i made mistake. Right now i should feel happy cos its working without any error. But have a small confusion for the permalink because its display:   1. `localhost/myblog/?news=breaking-news`   2. _**instead of:_** `localhost/myblog/news/breaking-news` anyone please provide me some idea how to get link like: `localhost/myblog/news/breaking-news` my permalink structure selected: > http//myblog/sample-post/ and its working for other post types.


Custom comments list, right depth

I created a custom comments_list() function, it works fine, the only problem is to show child comments inside the parent div. It works well with first and second depth levels but not for others. This is my code:               /* -----------------------------------------------------------------------------      * Comments custom functions      * -------------------------------------------------------------------------- */     //Custom comments lst     function t_one_comments_list( $comment, $args, $depth ) {         $GLOBALS['comment'] = $comment;         switch( $comment->comment_type ) :             case 'pingback' :             case 'trackback' : ?>             <li <?php comment_class(); ?> id="comment<?php comment_ID(); ?>">
<?php comment_author_link(); ?>
         <?php                 break;             default :         ?>
     <?php if ($depth == 1) {?>        <div <?php comment_class('media'); ?> id="comment-<?php comment_ID(); ?>">             <?php if ($comment->comment_approved == '0') : ?>
<?php _e('Your comment is awaiting moderation.', 't_one') ?>
             <?php endif; ?>
                     <?php echo get_avatar( $comment, 100 ); ?>

                             <?php comment_author(); ?>  <?php printf( __('%1$s', 't_one'), get_comment_date()) ?>                             <?php edit_comment_link(__(' Edit', 't_one'), ' ', '' ); ?>                             <?php comment_reply_link( array_merge( $args, array(                                      'reply_text' => __( 'Reply', 't_one' ),                                     'depth' => $depth,                                     'max_depth' => $args['max_depth']                                      ) ) ); ?>

<?php comment_text() ?>

                 <?php if ( $depth + 1) { ?>                 <div <?php comment_class('media'); ?> id="comment-<?php comment_ID(); ?>">             <?php if ($comment->comment_approved == '0') : ?>
<?php _e('Your comment is awaiting moderation.', 't_one') ?>
             <?php endif; ?>
                     <?php echo get_avatar( $comment, 100 ); ?>

                             <?php comment_author(); ?>  <?php printf( __('%1$s', 't_one'), get_comment_date()) ?>                             <?php edit_comment_link(__(' Edit', 't_one'), ' ', '' ); ?>                             <?php comment_reply_link( array_merge( $args, array(                                      'reply_text' => __( 'Reply', 't_one' ),                                     'depth' => $depth,                                     'max_depth' => $args['max_depth']                                      ) ) ); ?>

<?php comment_text() ?>

                      <?php } ?>
              <?php } ?>         <?php // End the default styling of comment             break;         endswitch;     }      What is the correct way to use $depth? Thanks in advance!


How to change post date only 1 time a day?

I have this code               is_admin() or add_action( 'the_post', function( $post ) {          if ( ! is_singular() or ! is_main_query() )         return;          $post->post_date     = current_time( 'mysql' );     $post->post_date_gmt = '';          wp_update_post( $post );      }); When refreshing the page, it will update to current time. But this will slow down my site. So how to update date time of page to current time **only 1 time per day** ? Example: I write a post on 5pm, June 6, 2013. And now, when I refresh page, it will change from 5pm, June 6 to 7pm, June 9. And in June 9, if I refresh the page, it will not change anything. Sorry for my poor English ! Thank you very much !


Conditional For get_the_author_meta

In post loop I'd like to setup a condition for get_the_author_meta. So if the author meta field is empty, then nothing is displayed. Below is what I have but it's not working.               <?php if(get_the_author_meta('twitter') ): ?>     <a href="https://www.twitter.com/<?php get_the_author_meta('twitter'); ?>" target="_blank">Twitter
     <?php else: ?>     No website     <?php endif; ?>


How to support special characters in text field?

When i put special characters in text field on wordpress themes option then it's gonna add some slash characters Like if I put               It's        then its show               It\'s.       How i solve that?


Error: Call to a member function get_error_code() on a non-object

I am getting the following error when with the code that I wrote for my plugin: Error: Fatal error: Call to a member function get_error_code() on a non-object in .../wp-login.php on line 335 I've tried to do a var_dump($errors) inside wp-login.php and it returns NULL. My Plugin: (Adds registered users to an external db)                function add_user_to_SF($errors, $sanitized_user_login, $user_email ) {           global $SF_USERNAME;      global $SF_PASSWORD;      global $errors;           try {        $mySforceConnection = new SforceEnterpriseClient();        $mySoapClient = $mySforceConnection->createConnection(CD_PLUGIN_PATH . 'Toolkit/soapclient/enterprise.wsdl.xml');        $mySFlogin = $mySforceConnection->login($SF_USERNAME, $SF_PASSWORD);          $sObject = new stdclass();     $sObject->FirstName = $_POST['user_login'];     $sObject->LastName = $_POST['user_login'];     $sObject->Email = $_POST['user_email'];          $createResponse = $mySforceConnection->create(array($sObject), 'Contact');          $ids = array();         foreach ($createResponse as $createResult) {             array_push($ids, $createResult->id);         }              } catch (Exception $e) {                $errors->add( 'demo_error', __('ERROR: There is a Salesforce problem.','mydomain') );           return $errors;          }           }           add_filter( 'registration_errors', 'add_user_to_SF', 10, 3 );      Additionally, when I test the process with this function, everything works smoothly.                 function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {         if ( empty( $_POST['first_name'] ) )             $errors->add( 'first_name_error', __('ERROR: You must include a first name.','mydomain') );              return $errors;     }      add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );


How to remove the Template drop down, but keep Parent and Order

I am about to turn a custom Wordpress site over to a client and do not want them to be able to choose/edit Templates, but need to allow them to sort the pages with Order and choose a Parent page. Is there a way to only remove the Template drop down from the Page Attributes option, but keep the Parent and Order options?


How can I add text to a single nav menu item?

I'm working on a theme that requires the end-user to specify the current performance season using a custom admin panel I've created, ie. "2013/2014", "2014/2015" etc., which I can retrieve using `get_option('current_season');` On my custom nav menu I have a page titled "Season" that needs the aforementioned field inserted into it so it reads "2013/2014 Season" rather than just "Season". The walker tutorials I have looked at only seem to show examples of adding a class to menu items but I need to add specific text to one menu item. How can I achieve this?


Unit testing for plugin development

I need to apply unit testing for one of my plugins. I recently re designed it into classes, so unit testing should be easier to apply now. What are some effective strategies to unit test my plugin? I need a way to use WordPress' functions used in the plugin, but I shouldn't need a running WordPress site (just test data on the DB AFAIK), right? I have a hard time figuring out how to just unit test the plugin and not the plugin in the site's context. I could use Selenium for this, but right now I just want to focus on unit testing the plugin classes functionality, so that I don't break them with each update.


Twenty Twelve Author not displaying

I have a WordPress blog. On which I want to display author name with each post.   I have tried various plugins but these don't work for me. This is the address of blog: http://altuslift.com/blog/ I want to show the name of author with date. Please help!


Temporary redirect prevents getting $_POST array

I'm sending a form from a woocommerce plugin. I've tweaked the `thankyou.php` page and added email sending functionality. However the $_POST array is empty. Inspecting with Chrome Dev Tools I found that there is temporary redirect from the posted page:![Chrome Dev Tools](http://i.stack.imgur.com/1b8Mu.png) The relevant form code: (in `/woocommerce/templates/checkout/form- checkout.php`)                 <form enctype="multipart/form-data" name="checkout" method="post"  id="checky" class="checky" action="http://pharma-job.shared6.lighthost.co.il/checkout/order-received">     <input type="hidden" name="admin_email" value="<?php echo get_option('admin_email'); ?>" />         <?php if ( sizeof( $woocommerce_checkout->checkout_fields ) > 0 ) : ?>                  <?php do_action( 'woocommerce_checkout_before_customer_details'); ?>

                          <?php do_action('woocommerce_checkout_billing'); ?>

                          <?php do_action('woocommerce_checkout_shipping'); ?>

             העלה קו"ח:        <input type="file" name="cv_file">              <?php do_action( 'woocommerce_checkout_after_customer_details'); ?>
<?php _e('Your order', 'woocommerce'); ?>
              <?php endif; ?>              <?php do_action('woocommerce_checkout_order_review'); ?>          </form>      I looked at the generated HTML and found what appears to be the smoking gun:               <input type="hidden" name="_wp_http_referer" value="/checkout/" />      But what is the mechanism behind this redirect? How do I bypass it?


Checking if Database Table exists

I read the wordpress codex and professional wordpress. It seems both use something like               if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {      to determine if the table exists. Is there any reason why `CREATE TABLE IF NOT EXISTS ( ... )` is not used? It will check and create the table in 1 query, won't it be better? Or am I missing something?


RSS Widget on theme

I want to display some external RSS Feeds in my theme - not on a sidebar - just before a homepage content that I'm building. Is there a core shortcut or method to display RSS on themes?


Has anyone experience w/ WordPress (MultiSite) hidden users (possibly hacked)?

I have 2 WordPress MultiSite installs (on different accounts, but under the same HostGator reseller a/c) and both seem to have been compromised. I say "compromised" because the user_logins have been modified (somehow) and "hidden users" are being shown via WP Admin. I attempted to login to the installs which are both up-to-date (3.1) MultiSites. I use 1PassWord (with 50 character alpha + numerical + symbolic passwords) so weak passwords are not the hole. My logins (which I use every day) were rejected so I knew there was trouble. I can access phpMyAdmin and sure enough the user_logins and user_email had been modified. And if I change them via phpMyAdmin, 5mins later they were re- edited (now it seems I can't even do this). * Interestingly, I don't think you can change a username in WP Admin (it is ghosted and uneditable). Does this mean they are hacking in external to WP Admin in order to change this? Also, in the User Dashboard, 3 users are displayed, but the count (up the top) indicates there are 5 users in total. Super Admin is a simular story - it shows the tally as "3 Super Admins" but only 1 is displayed. (I have checked the source code and used Web Dev tools to try and find hidden content in these admin pages, but no joy). I had hoped to add new Super Admin and delete old super admin (after porting posts to new user admin user). But I am unable to delete the original Super Admin user (ID=1) even after creating new Super Admin and removing Super Admin privileges from ID=1. When I click "delete" (on hover of User ID=1) nothing happens; the page simply refreshes. HostGator have been suprisingly helpless, arguably hopeless, and VERY slow to deal with this matter. Which is ongoing. Can anyone give me some advice or help in any way.


Can I attach a plugin via my add_filter callback contents?

I'm trying to add my plugin interface to the Category Editor. I've easily attached it to the post and page editor using the add_meta_box() filter, but there does not appear to be an add_meta_box hook on the category editor. So, since I'm already adding some extra fields to the category edit screen using add_filter('edit_category_form', 'my_category_editor_function', 1) I'm wondering if I can just call my plugin script from within that function? Example:               add_filter('edit_category_form', 'my_category_editor_function', 1);     function my_category_editor_function($tag) {         $tag_extra_fields = get_option('my_category_editor_function');?>
         <?php              /*             load my widget here. May have to use some funky css to get it to float              to the right of the cat editor just like it does in the post editor             */         ?>

             Category Title	             <input name="_my-categoryTitle" id="_my-categoryTitle" type="text" size="40" aria-required="false" value="<?php echo $tag_extra_fields[$tag->term_id]['my_cat_title']; ?>" />
The title is optional but will be used in place of the name on the home page category index (when in list view) and on the category landing page.

             Keywords	             <input name="_my-categoryKeywords" id="_my-categoryKeywords" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_keywords']))echo $tag_extra_fields[$tag->term_id]['my_cat_keywords']; ?>" />
Optional: If you want to add a keywords metatag to the category landing page and keywords in the Category image's alt tag.

             Image Link	             <input name="_my-categoryImageLink" id="_my-categoryImageLink" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_imageLink']))echo $tag_extra_fields[$tag->term_id]['my_cat_imageLink']; ?>" />
Optional: If you want to link the category landing page image to an affiliate or CPA offer, place your link here.

             Hide Ads?	             <input name="_my-categoryAds" id="_my-categoryAds" type="checkbox" style="width:30px;float:left;"<?php if(isset($tag_extra_fields[$tag->term_id]['my_cat_ads'])) echo ' checked="checked"'; ?>" />
Check this to remove ads from this category's landing page. (Does not affect ads placed in widgets)


Filter list of rules based on a capability

I'm trying to get a list of roles and filter them by a specific capability (custom). I've ran across this post, but I'd like to filter the roles by whether they're capable to, say, `edit_post`. -Zack


Getting custom taxonomy posts on archive page

Hi I am not sure if the question is understandable or not but what I am trying to achieve I will explain. I have a custom post type called menu item and custom taxonomy called menu item type. CODE               function create_menu_post_type()      {         $labels = array(             'name' => __( 'Food Menu','framework'),             'singular_name' => __( 'Menu Item','framework' ),             'add_new' => __('Add New','framework'),             'add_new_item' => __('Add New Menu Item','framework'),             'edit_item' => __('Edit Menu Item','framework'),             'new_item' => __('New Menu Item','framework'),             'view_item' => __('View Menu Item','framework'),             'search_items' => __('Search Menu Items','framework'),             'not_found' =>  __('No Menu Item found','framework'),             'not_found_in_trash' => __('No Menu Item found in Trash','framework'),              'parent_item_colon' => ''           );                $args = array(             'labels' => $labels,             'public' => true,             'exclude_from_search' => false,             'publicly_queryable' => true,             'show_ui' => true,              'query_var' => true,             'menu_icon' => get_template_directory_uri() . '/images/menu.png',             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => 5,             'supports' => array('title','editor','thumbnail'),             'rewrite' => array( 'slug' => __('menu-item', 'framework') )           );                 register_post_type('menu-item',$args);     }     add_action( 'init', 'create_menu_post_type' );               function create_menu_item_type_taxonomy(){              $labels = array(             'name' => __( 'Menu Item Types', 'framework' ),             'singular_name' => __( 'Menu Item Type', 'framework' ),             'search_items' =>  __( 'Search Menu Item Types', 'framework' ),             'popular_items' => __( 'Popular Menu Item Types', 'framework' ),             'all_items' => __( 'All Menu Item Types', 'framework' ),             'parent_item' => __( 'Parent Menu Item Type', 'framework' ),             'parent_item_colon' => __( 'Parent Menu Item Type:', 'framework' ),             'edit_item' => __( 'Edit Menu Item Type', 'framework' ),              'update_item' => __( 'Update Menu Item Type', 'framework' ),             'add_new_item' => __( 'Add New Menu Item Type', 'framework' ),             'new_item_name' => __( 'New Menu Item Type Name', 'framework' ),             'separate_items_with_commas' => __( 'Separate Menu Item Types with commas', 'framework' ),             'add_or_remove_items' => __( 'Add or Remove Menu Item Types', 'framework' ),             'choose_from_most_used' => __( 'Choose from the most used Menu Item Types', 'framework' ),             'menu_name' => __( 'Menu Item Types', 'framework' )         );              register_taxonomy(             'menu-item-type',              array( 'menu-item' ),              array(                 'hierarchical' => true,                  'labels' => $labels,                 'show_ui' => true,                 'query_var' => true,                 'rewrite' => array('slug' => __('menu-item-type', 'framework'))             )         );      }          add_action( 'init', 'create_menu_item_type_taxonomy', 0 );      I have created a post named sushi under the term japenese. And then created post named chow mein under the term chinese.I want to populate archive posts by different terms. I have an archive page i.e archive.php where I am populating posts but my code populates all posts from all terms.               <?php $loop = new WP_Query( array( 'post_type' => 'menu-item', 'posts_per_page' => -1 ) ); ?>                 <?php while ( $loop->have_posts() ) : $loop->the_post();                     get_template_part( 'content', get_post_format() );                     endwhile; wp_reset_query();                 ?>                      <?php else : ?>                     <?php get_template_part( 'content', 'none' ); ?>                 <?php endif; ?>      I am navigating to the archive page via dynamic sidebar               <?php dynamic_sidebar( 'Archive' ); ?>      Please note that I have used the custom post type and the taxonomy code from a theme as a reference. Also if this is by any way a non-valid question feel free to comment and I will delete the question and try to find some other solution. Adding a clearer example               Custom post -> menu-item     menu-item -> 2 posts -> sushi, chow mein     taxonomy -> menu-item-type     menu-item-type -> japenese, chinese     sushi -> japenese     chowmein -> chinese


List post from current taxonomy children

I have a custom post type and a taxonomy with children, with a template file named taxonomy-productcategories.php. On this i want to list all children with their posts.   * Child taxonomy 1     * Child taxonomy 1 Post A     * Child taxonomy 1 Post B     * Child taxonomy 1 Post C   * Child taxonomy 2     * Child taxonomy 2 Post D     * Child taxonomy 2 Post E     * Child taxonomy 2 Post F And so on... I have an example for getting just the Child taxonomy, but i want to add the post from each taxonomy.               <?php     $term_slug = get_query_var( 'term' );     $taxonomyName = get_query_var( 'taxonomy' );     $current_term = get_term_by( 'slug', $term_slug, $taxonomyName );     $termchildren = get_term_children( $current_term->term_id, $taxonomyName );          foreach ($termchildren as $child) {         $term = get_term_by( 'id', $child, $taxonomyName );         echo "$term->name:<br />";           }     ?>


Custom widget breaking widget section in admin menu

I am building a child theme at http://habitat.erniehigh.com for a client. I need to add custom widget that shows recent posts by category. I have built similar widgets elsewhere using basically the same code.                   class habitat_posts extends WP_Widget {       function habitat_posts(){     $widget_ops = array(     'description' => 'Allows you to display a list of recent posts within a particular category.');     $this->WP_Widget('fromcat-widget', 'Recent posts from a Category', $widget_ops);     }      function form($instance) {     //widgetform in backend     $name = $instance['title'];     $numberposts = $instance['numberposts'];     $catid = $instance['catid'];     $rss = $instance['rss'];     ?>      <?php   }  // end of the instance      function update( $new_instance, $old_instance ) {         $instance = $old_instance;         $instance['catid'] = $new_instance['catid'];         $instance['numberposts'] = $new_instance['numberposts'];         $instance['title'] = $new_instance['title'];         $instance['rss'] = $new_instance['rss'];         return $instance;         } // end the updated        function widget( $args, $instance ) {            extract($args, EXTR_SKIP);              $title = $instance['title'];              $catid = $instance['catid'];               $numberposts = $instance['numberposts'];                       $posts = get_posts('numberposts='.$numberposts.'&category='.$catid);                        $out = '
';                   foreach($posts as $post) {                   $out .= '
ID).'">'.$post->post_title.'
';                      }               $out .= '
';              echo $before_widget;              echo $before_title.$title.$after_title;               echo $out;               echo $after_widget;               } // end of widget function           }  // end the whole process ready to register              register_widget('habitat_posts');      When I try to use it on the child theme here everything goes OK except the Widget area in the backend is a jumbled up mess. The new widget is visible and the form fields for creating a new instance are visible and I can drag it to a sidebar but that is all. Thanks for any suggestions or help Ernie


is_wp_error() and handling errors

Im trying to build a function which grabs the feedburner "readers" using `wp_remote_get()`. I noticed that it frequently returned a value of `0`. I assumed at first that it was a WordPress error (handled by `is_wp_error()`) or a flaw with `wp_remote_get()`. Wrong of-course.. Feedburner just kept crashing, so I used a second transient to store a result (never `0`) with an expiration of 7 days. The part which i cant get my head around is handling errors with `is_wp_error()`. I need to force an error so i can handle it properly, before I put it up on production. Heres an illustration:               $result = wp_remote_get( 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . urlencode($username) );          if ( is_wp_error($result) )         return false;      Whats the best way to force an error? Should i use `new WP_error()`?


Adding header logo instead of text

I want to add Header logo instead of the text "physics for All " in the following site. I think , i have to add my logo to my site then , i will have to insert the image link to the `header.php` option . I am using spacious wordpress theme. Can you suggest me that which one will i need to remove and to add to set the logo.


Exclude User from Activity Stream in BuddyPress?

I'd like to exclude a specific user account from showing up in the activity stream. I found this code that's supposed to exclude the Admin. Any clue how to exclude a specific user? (this code goes in bp-custom.php)               <?php      add_action("plugins_loaded","bpdev_init_sm_mode");     function bpdev_init_sm_mode(){     if(is_site_admin())     remove_action("wp_head","bp_core_record_activity");//id SM is on, remove the record activity hook     }     ?>      Thank you.


Display recent posts from the same category as current post in sidebar

I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but something's not ok:                   $category = get_the_category($post->ID);          $current_cat = $category[0]->cat_name; //This will get me the first category assigned to the current post but since every post has only ONE cat. assigned to, it's good enough        //Next, in my sidebar widget I have this:         $my_query = new WP_Query('category_name='.$current_cat.'&showposts=10');         while ($my_query->have_posts()) : $my_query->the_post();         ...display my titles here ...         unset($current_cat); //I'm not sure I need to unset this variable?         endwhile;      I'm not really a programmer so I'm struggling with understanding the logic but I'd like to learn. Any suggestions/help much appreciated! Thank you, Alex


Add image to media library from URL in uploads directory

The plugin "Video Embed & Thumbnail Generator" does a great job of generating thumbnails from videos. It saves the thumbnail URL as metadata for the attachment. The thumbnail gets added to the uploads directory. Is there a way to take this image and add it to the media library so i can pass the image through the image_downsize function to create thumbnail of a different size? wp_insert_attachment looks like it needs a path to a file and not a URL, or am i mistaken? how can i add a URL to the media library? this is possibly a duplicate of How can I get an image from the uploads dir and enter it in the media library? but that never got any answers.


My Gallery Photos are showing in the post's excerpts

I just can't win with this project! All of a sudden, each post's gallery photos are showing up in the excerpt/preview of the post. Each post has a gallery of images that should only be visible on the actual post's page. Can anyone see what might be causing this? Here is my code:               if ( has_post_thumbnail() ) {          the_post_thumbnail();     }     else {          get_the_image( array('size' => 'thumbnail',                               'image_class' => 'wp-post-image'));        }      Then in my functions file:               // This theme displays custom size (page-single) featured image on the Post's  page          function InsertFeaturedImage($content) {              global $post;              $original_content = $content;              if ( current_theme_supports( 'post-thumbnails' ) ) {                  if ((is_page()) || (is_single())) {                      $content = get_the_image( array( 'size' => 'full' ) );                 $content .= $original_content;             }         }         return $content;     }          add_filter( 'the_content', 'InsertFeaturedImage' );      You can view the site in question here: http://dependablecarcompany.com You'll see the horribly broken site in question. There should only be the ONE excerpt representative thumbnail there, and not all the thumbs from the gallery too. Thank You!


Error with /wp-admin/install.php

I have installed Wordpress many times and never encountered an issue. However I just installed it on a folder (public_html) and after setting up the config.php file it doesn't work. Alledgedly all my information is correct since it doesn't return database error on /wp-admin but redirects to /wp- admin/install.php. However the install.php doesn't load at all. In chrome I get:               The website encountered an error while retrieving http://www.chirie-sanchez.com/wp-admin/install.php. It may be down for maintenance or configured incorrectly.          HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.      The problem seems to be around here, since I can write anything before but not after:               /** Load WordPress Bootstrap */     require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );          /** Load WordPress Administration Upgrade API */     require_once( dirname( __FILE__ ) . '/includes/upgrade.php' );          /** Load wpdb */     require_once(dirname(dirname(__FILE__)) . '/wp-includes/wp-db.php');      I tried changing those with relative URLs and still didn't work. I don't know what to do? What could be the issue?


Editing options pages?

I'm trying to find a way of adding a single checkbox to one of the existing options pages, most likely options-reading.php programmatically. Unfortunately, I haven't found any good references on this. Any thoughts from the community?


CPT Template Not Showing - Getting 404

I'm developing a Custom Post Type plugin, which works fine in dev. Now that I've moved it to production, I'm getting a 404 when I try to display the template for the CPT. So, two questions: 1- Is there some mechanism to determine the path WP took to get through the hierarchy? 2- Why wouldn't it just give me the single or index page? I've dumped $wp_query and a stacktrace at the end of the 404. Here's part of what I found:               [query] => Array         (             [page] =>              [pagename] => refletters/proximity         )          [request] => SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND (wp_posts.ID = '0') AND wp_posts.post_type = 'page'  ORDER BY wp_posts.post_date DESC      [posts] => Array         (         )          [queried_object] =>      [queried_object_id] => 0      And the stack trace:               2013-04-27 22:16:41 - 24.52.197.40 - TRACE - index.php - 404.php[39] -          wordpress/wp-content/themes/notoriousconsultant/404.php[39] - aaLog->logtrace         wordpress/wp-includes/template-loader.php[50] - include         wordpress/wp-blog-header.php[16] - require_once         wordpress/index.php[17] - require      Thanks for your help.


Roots: Custom Post Type 404 Not Found

So I'm trying to create a custom post type for my theme. I've written the function to register the post type and I can add a post from the admin panel, but when I try to view the new post's permalink, I get a 404 not found page. Here's my post type function:               add_action( 'init', 'create_press_coverage' );          function create_press_coverage() {         register_post_type( 'press_coverage',             array(                 'labels' => array(                     'name' => 'Press Coverages',                     'singular_name' => 'Press Coverage',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Press Coverage',                     'edit' => 'Edit',                     'edit_item' => 'Edit Press Coverage',                     'new_item' => 'New Press Coverage',                     'view' => 'View',                     'view_item' => 'View Press Coverage',                     'search_items' => 'Search Press Coverage',                     'not_found' => 'No Press Coverages found',                     'not_found_in_trash' => 'No Press Coverages found in Trash',                     'parent' => 'Parent Press Coverage'                 ),                      'public' => true,                 'menu_position' => 8,                 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),                 'taxonomies' => array( '' ),                 'has_archive' => true             )         );     }      I'm using the roots starter theme. Is there some extra configuration I need to do to make custom post types work with it? Thanks.


I am creating custom post type now i am creating for this post type single page but getting page isn't found

I am creating custom post as per given code add_action( 'init', 'create_post_type' ); function create_post_type() {               register_post_type( 'slider',             array(                 'labels'        => array(                 'name'          => __( 'Slider' ),                 'singular_name' => __( 'Slider' )                 ),         'supports'    => array( 'title', 'editor', 'thumbnail'),             'public'      => true,         'has_archive' => true,         )     );      } also creating themesfolder/single-slider.php but data is not getting page redirect on page isn't found.


Archive of custom post type returns 404

I have created a custom post type "video" (see my functions.php below) and it should return an archive on mysite.com/video but instead I get a 404. **Functions.php**               // Video's     add_action( 'init', 'register_cpt_video' );          function register_cpt_video() {              $labels = array(              'name' => _x( 'Video\'s', 'video' ),             'singular_name' => _x( 'Video', 'video' ),             'add_new' => _x( 'Voeg nieuwe toe', 'video' ),             'add_new_item' => _x( 'Voeg nieuwe video toe', 'video' ),             'edit_item' => _x( 'Bewerk video', 'video' ),             'new_item' => _x( 'Nieuwe video', 'video' ),             'view_item' => _x( 'Bekijk video', 'video' ),             'search_items' => _x( 'Zoek video\'s', 'video' ),             'not_found' => _x( 'Geen video\'s gevonden', 'video' ),             'not_found_in_trash' => _x( 'Geen video\'s in de prullenbak gevonden', 'video' ),             'parent_item_colon' => _x( 'Parent Video:', 'video' ),             'menu_name' => _x( 'Video\'s', 'video' ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => 'Gebruik dit posttype om video\'s te posten',             'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes' ),             'taxonomies' => array( 'post_tag' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 11,                  'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => array(                  'slug' => 'videos',                 'with_front' => true,                 'feeds' => true,                 'pages' => true             ),             'capability_type' => 'page'         );              register_post_type( 'video', $args );     }      I am working with Buttercream as a parent theme. I have a similar cpt ("foto") and that one does work flawlessly. Very strange. If it helps, this is the site: http://www.denotenbalkers.be/fotos/ (As you can see, `/fotos` works, but the "Video's" link in the nav does not.) ## EDIT 1 (22-4-2013) I tried adding another cpt, but it gives the same problem: I can create a post with that type, but when I want to view it, I get a 404.               add_action( 'init', 'register_cpt_filmpje' );          function register_cpt_filmpje() {              $labels = array(              'name' => _x( 'Filmpjes', 'filmpje' ),             'singular_name' => _x( 'Filmpje', 'filmpje' ),             'add_new' => _x( 'Voeg nieuw toe', 'filmpje' ),             'add_new_item' => _x( 'Voeg nieuw filmpje toe', 'filmpje' ),             'edit_item' => _x( 'Bewerk filmpje', 'filmpje' ),             'new_item' => _x( 'Nieuw filmpje', 'filmpje' ),             'view_item' => _x( 'Bekijk filmpje', 'filmpje' ),             'search_items' => _x( 'Zoek filmpjes', 'filmpje' ),             'not_found' => _x( 'Geen filmpjes gevonden', 'filmpje' ),             'not_found_in_trash' => _x( 'Geen filmpjes in de prullenbak gevonden', 'filmpje' ),             'parent_item_colon' => _x( 'Parent Filmpje:', 'filmpje' ),             'menu_name' => _x( 'Filmpjes', 'filmpje' ),         );              $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => 'Gebruik dit posttype om filmpjes te posten',             'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes' ),             'taxonomies' => array( 'post_tag' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 11,                  'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => array(                  'slug' => 'filmpjes',                 'with_front' => false,                 'feeds' => false,                 'pages' => true             ),             'capability_type' => 'page'         );              register_post_type( 'filmpje', $args );     }


Why do all my custom post types return a 404, even after resetting the permalink?

I have two custom post types setup like this:               add_action( 'init', 'create_post_type_News' );     function create_post_type_News() {         register_post_type( 'news',             array(                 'labels' => array(                     'name' => __( 'News' ),                     'singular_name' => __( 'News' )                 ),             'public' => true,             'has_archive' => true,             'supports' => array(                 'title',                  'editor',                  'author',                  'thumbnail'             )             )         );     }      when I try to view the page (`/%postname%/` is used as permalink) I get the standard 404 message "Not Found Apologies, but the page you requested could not be found. Perhaps searching will help." I've tried the standard fix:   * set permalink back to default and save   * set permalink back to desired style and save The page **will** show with permalinks as default but not customized.


Naming convention for taxonomies

I had a taxonomy called: `wossom`. And I was using `taxonomy-wossom.php` as the template file that will describe a term of this taxonomy. Now I need to change the name of the taxonomy to `wossom-balag`, so I changed the name of the template to `taxonomy-wossom-balag.php`. But the page is not working correctly. Is the cause of the problem the fact that I am not respecting naming convention for the hierarchy? Thank you very much


How to know when an user is loged in?

Hello i have this simple problem: when the user is logged an podcast player is shown, other case no. How verify when the user is logged? Im wordpress and php newbie. Thankx


Gravity Forms | Form Object is NULL

I am trying to customize some gravity forms behavior. Therefore I've tried to hook into gforms from my theme. Unfortunately the form object is always `NULL`. Why is that the case? Example code:               1)     add_action('gform_confirmation', 'myCustom_gform_confirmation');     function myCustom_gform_confirmation($confirmation, $form) {         var_dump($confirmation);         var_dump($form);         die();     }          2)     add_action('gform_after_submission', 'myCustom_gform_after_submission');     function myCustom_gform_after_submission($entry, $form) {         var_dump($entry);         var_dump($form);         die();     }


How to override a parent theme framework php file in child theme

I have a theme which is using a custom framework to create custom post types, I want to extend it in child theme so that I will use the same methods to create a new custom post type in child theme. I cannot write custom code I must use the original classes to extend the functionality in child theme. The problem is I am unable to override any of the parent theme framework files. The standard files can be overridden but framework files (in a folder like parenttheme/framework/php/anyfilehere.php) cannot be overridden. I have duplicated the same folder structure and tried to override the file by creating a same name file, but it does not work.


What's wrong with my wp database query?

$cats = $wpdb->get_results('SELECT term_id, term_taxonomy_id, taxonomy, parent      FROM wp_terms, wp_term_taxonomy      WHERE term_id = term_taxonomy_id      AND parent = 1     AND taxonomy = "category"', ARRAY_A);      I'm trying to get all the categories in my database that are children of the category of ID 1, but it's not working. What's wrong ?


Import images from self-hosted to WordPress.com

I'm trying to migrate my self-hosted WP blog to WordPress.com, images included. Originally images were hosted on various image-hosting websites, but I've used this plugin to cache and upload them to my self-hosted WP media library. Now posts have image tags in this format:               <img src="http://mywebsite.com/wp-content/uploads/2012/02/2033_l.jpg" alt="" />      I've exported my blog to XML, and used the import tool on WordPress.com. The blog is imported fine, and all images have been added to WordPress.com media library. However, image urls in each post still link to my self-hosted (old) blog. I've contacted their support regarding this issue, and they say I have to change each of the 650~ image urls manually. Is there an easy way of doing this? I can do a _search & replace_ on the exported XML file, but there must be some easier way of importing the urls correctly.


How to update post taxonomies (Creating a custom UI for Custom Taxonomy)

I have a taxonomy eg. authors. I want to create a custom UI for. I think integrating with a Meta Box together with other post meta will make things easier for the user. Also I think a jQuery UI AutoComplete (Multiple comma separated values) is more appropriate So I will need to know how I can "update_post_taxonomy". I suppose I will need to   * if taxonomy does not exists      * create it   * if post does not have the taxonomy term      * add it   * remove terms that are not specified by user I am sure there are functions for this?


How to sort categories by id in wordpress admin

I would like to know if it is possible in Wordpress admin to show categories in `post-new.php` and `edit-tags.php?taxonomy=category` sorted by id NOT by category name.


How do I call comments_template(); from a plugin file?

I am trying to call `comments_template();` from a plugin file. Specifically, it's the `player.php` file from the plugin All Video Gallery. Below is the file itself.               <?php          require_once('ismobile.php');          /******************************************************************     /* Build Player     ******************************************************************/     class Player {              var $width, $height;              public function buildPlayer( $profileid = 1, $videoid = 1, $autodetect = 1 ) {             global $wpdb;                         $profile      = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_profiles WHERE id=".$profileid);                  $this->width  = $profile->width;             $this->height = $profile->height;                  if( isset($_GET['slg']) && $autodetect == 1 ) {                 $slug    = $_GET['slg'];                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE slug='$slug'");                 $videoid = $video->id;             } else {                 $video   = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_videos WHERE  id=".$videoid);             }                     if($video->type == 'thirdparty') {                 $result    = '
width . 'px; height:' . $this->height . 'px;">';                 $result   .= $video->thirdparty;                 $result   .= '
';             } else {                 $arr_params = array();                   $custpage   = ( $profile->custom_page_url ) ? $profile->custom_page_url : $this->curPageURL();                 if( isset($_GET['catid']) ) {                     $arr_params['catid'] = $_GET['catid'];                 }                 if( isset($_GET['sort']) ) {                     $arr_params['sort'] = $_GET['sort'];                 }                        $flashvars = 'base='.get_option('siteurl').'&wp=1&vid='.$videoid.'&pid='.$profileid.'&page='.urlencode( @add_query_arg($arr_params, $custpage) );                 $detect    = new IsMobile();                             $result    = $detect->isMobile() ? $this->gethtmlplayer( $profile, $video ) : $this->getflashplayer( $profile, $flashvars );                 }                         $this->updatehits( $video->slug );                  $cust_class = ( $profile->custom_player_class ) ? $profile->custom_player_class : 'avs_player';                  $output  = '' . "\n";             $output .= '
width.'px;">' . "\n";             if($profile->title) {                 $output .= '
'.$video->title.'
' . "\n";             }             if($profile->category) {                 $output .= '
Category : '.$video->category.'
' . "\n";             }             if($profile->hits) {                 $output .= '
Hits : '.$video->hits.'
' . "\n";             }             $output .= '

' . "\n";             $output .= $result . "\n";             if($video->description) {                 $output .= '
'.$video->description.'
' . "\n";             }             $output .= '
' . "\n";                  return $output;         }              public function getflashplayer( $profile, $flashvars ) {             global $allvideogallery_plugin_dir;                  $siteurl = get_option('siteurl');             $src     = $siteurl . '/wp-content/plugins/' . $allvideogallery_plugin_dir . '/player.swf?random=' . rand();                  $result  = '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '<object type="application/x-shockwave-flash" data="' . $src . '" width="' . $this->width . '" height="' . $this->height . '">';             $result .= '<param name="movie" value="' . $src . '" />';             $result .= '<param name="wmode" value="opaque" />';             $result .= '<param name="allowfullscreen" value="true" />';             $result .= '<param name="allowscriptaccess" value="always" />';             $result .= '<param name="flashvars" value="' . $flashvars . '" />';             $result .= '</object>';             $result .= '</object>';                  return $result;         }              public function gethtmlplayer( $profile, $video ) {             if($video->type == 'youtube') {                 $url_string = parse_url($video->video, PHP_URL_QUERY);                 parse_str($url_string, $args);                 $result  = 'width.'" height="'.$this->height.'" ';                 $result .= 'src="http://www.youtube.com/embed/'.$args['v'].'" frameborder="0" allowfullscreen>';             } else {                 $preview = $video->preview ? 'poster="' . $video->preview . '"' : '';                 $result  = '<video onclick="this.play();" width="'.$this->width.'" height="'.$this->height.'" '.$preview.' controls>';                 $result .= '<source src="'.$video->video.'" />';                 $result .= '</video>';             }                  return $result;         }              function curPageURL() {             $pageURL = 'http';                   if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}}              $pageURL .= "://";              if ($_SERVER["SERVER_PORT"] != "80") {                  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];              } else {                  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];              }                   return $pageURL;         }              function updatehits( $slug ) {             global $wpdb;                  $table_name = $wpdb->prefix."allvideogallery_videos";             $video = $wpdb->get_row("SELECT * FROM $table_name WHERE slug='$slug'");                     $count = ($video) ? $video->hits + 1 : 1;             $video->hits = $count;                  $wpdb->update($table_name, array('hits' => $video->hits), array('id' => $video->id));         }          }          ?>      I've tried adding `comments_template();` right before the `?>` but nothing shows up. Is there another way to call that function when it's not a theme file?


Absolute path to stylesheet_dir/images/my_img.jpg does not work?

I am manipulating an img element in functions.php using jQuery by changing the src attr on hover. How do I make so the absolute path works? Currently, when I view the image directly in the browser it brings me to 404 page. Relative path doesn't work either.


The revisions table in my database is at 70% capacity and growing. What should I do?

I installed the Wordpress System Health Plugin and it says that the revisions table in my database is at 70% capacity with 994 rows. I don't fully understand what this means. I anticipate that my site will get much larger than it is today. Questions   * Am I going to run into trouble or is there some way I can increase that table's capacity?    * Is it a hosting issue?  One proactive thing I have done is set a max number of post revisions to 4. Any solution or an explanation to help me understand what's going on would be really appreciated. Thanks for your help.


How to show description under an inserted image?

I'm using wordpress' native media manager. I have a problem. I can show the title under the image. But I want also to show the description. Is it possible to do?


Custom Post Custom Taxonomy Data Not Saving in Edit Screen

I have a custom post type "projects" with a custom taxonomy "project_type." If I select a project type taxonomy within the post editor screen and hit update, the taxonomy isn't updated. Worse yet, it clears all taxonomy values associated with that project. Oddly, I added a column in the admin screen to display the custom taxonomy values and I am able to update the taxonomy values via WP's built-in quick edit feature. Here is the bulk of the custom post type and taxonomy code: http://pastebin.com/2TdmVEAE So, I'm thinking I need some function that will amend the save post function to include the custom taxonomy data. Right now the save_post function must not include custom taxonomies in a custom post type, and that is why it is clearing the data. (side: why does it work with quick post?) I just don't know how exactly to handle the data in the custom taxonomies to compare/write the selected taxonomies to the specific post. I've just discovered the codex on save_post... Here's what I have so far, built off another post that is similar:               add_action('save_post', 'dcg_taxonomy_save');          // Save data from meta box     function dcg_taxonomy_save($post_id) {     global $post;          // verify nonce     if (!wp_verify_nonce($_POST['project_type'], basename(__FILE__))) {         return $post_id;     }          // check autosave     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {         return $post_id;     }          // check permissions     if ('page' == $_POST['project']) {         if (!current_user_can('edit_page', $post_id)) {             return $post_id;         }     } elseif (!current_user_can('edit_post', $post_id)) {         return $post_id;     }          $old = wp_get_post_terms($post_id, 'project_type', array("fields" => "all") ); // grabs all terms for this post in the taxonomy     $new = $_POST[ ...?... ]; // <-- how do I grab the custom taxonomy values          // probably need to run a foreach through the array of taxonomy values, yea?     if ($new != $old) {         wp_set_post_terms($post_id, $new, 'project_type', false ) // sets new taxonomy terms     }     }


comment_post callback function: how to run it in the background.

I'm calling a custom function when someone submits comments using the following to plug into the comment_post action: add_action('comment_post', 'MY_FUNCTION'); The problem is that my function is extremely heavy, causing about a 5 second delay between the time when someone submits a comment to the time when the page refreshes and they view their comment. Is there any way that my custom function could run in the background, so that they could be redirected right away? Alternatively, would it be safe to redirect them directly at the top of my function, then run the rest of my function after they had already been redirected?


Wordpress doesn't load HTML

All, I'm trying to have a side navigation menu that once you click on a link it basically pulls the content of that wordpress page and displays it. I've got the following code to do this:               $qry = "Select post_content from wp_jjfuap_posts where ID='$menu->object_id'";     $result = mysql_query($qry);     $resultset = mysql_fetch_array($result);     $output = apply_filters( 'the_content', $resultset['post_content'] );      The issue is that it doesn't translate any HTML. It simply just displays the HTML. For example, it will output the following:

Test

Another test

     Blah
Al
 Person
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia justo quis neque da
      How can I get Wordpress to actually display the correct HTML using this method? Thanks!


Customize search page

When I just click search, wordpress takes me to the 404 page. I'd like to just have a search template (maybe a page) that does search. Can anyone help? **UPDATE:** I created a custom search page (link), and changed things around in my header file to reflect the custom search page, however now the search is broken. Can you check out the code and help me out?


Using CSS ID's and Classes with images in a Wordpress Horizontal Menu

just found this marvelous website, so, I'm new in Wordpress. I have a HTML/CSS website developed from a PSD file. Everything was going OK, Header, Footer, but when I came across the WP menu, I'm just stocked. Here's a code menu example:

     etc etc

      And the CSS for one example:                a#menunews, a#menunews:link, a#menunews:visited, a#menunews:active {     background: transparent url(imagens/menu/menu_news.png) no-repeat left top;     display: block;     height: 55px;     width: 56px;      }      a#menunews:hover {background-position: left bottom;}      Then I found that WP menus accepts classes, and I turn some of these itens into:               .menunews {     background: url(images/menu/menu_news.png) no-repeat left top;     height: 55px;     width: 56px;     display:block;     }      and                   #navmenu li:hover {     background-position: left bottom;     }      My question is, can I build the menu using the first structure, with the ID's? I have no idea where the wp_menu list outputs are... And using the classes, inside the menu admin panel, it works, but the Page Title stays above the image and the link works only on it, not in the image itself, like a block, like the original CSS. For visual purposes, the menu should look like this website: http://www.realmofobscura.com/ it is by the way made with WP. tutorials, links, anything, will be highly appreciated =)


How to use wp_nav_menu to create a select menu dropdown?

I'm using the following inside the `wp_nav_menu` function to create a select dropdown menu where each menu item is an option in the select dropdown...               'items_wrap' => '<select>%3$s</select>'     'before'     => '<option value="">'     'after'      => '</option>'      How do I add the link value in the `'before'` declaration? Is there a better way to go about this? I know about `wp_dropdown_pages`, but that doesn't work because I want users to be able to control the menu from the "Menus" page.


Using wordpress post data as input for google visualisations

I'm trying to use wordpress post data (eg title, link, custom fields) as a data source for google visualisations. I want to be able to take the wordpress data for all posts and visualise using the "table" and "motion" charts. Related doc http://code.google.com/apis/chart/interactive/docs/gallery/table.html http://code.google.com/apis/chart/interactive/docs/gallery/motion.HTML How do I loop though all my posts to create an array that that will work as a data source? I want to get post titles, post urls and associated custom fields for graphing. Hope you can help!


Adding Alt Attributes Automatically when Uploading Images to Media Library

I have lots of images that has to be uploaded via media library. I want to know, is it possible to add file name to `alt` attribute field automatically when I am uploading them? At the moment I have to open each image and add the `alt` attribute manually.


How to create a category or tag available exclusively to the admins and not to the users?

I would like to create a category or tag name that is available only to the admin(s) and not to the authors. For example, I would like to create a category or tag called `Exclusive Content`. Now only admins should be able to add this category or tag to their posts. Other users should not be able to see it or use it. Is it possible?


Locale switching with a "language" taxonomy

I know that it's possible to switch the WP locale by using URL paramaters, as described here, but I'm trying to build a method that would entirely rely on a custom "Language" taxonomy. What I currently have is a simple plugin, that registers the language taxonomy and implements a locale switch if the taxonomy is present:               <?php     add_action( 'plugins_loaded', 'wpsx_register_taxonomies' );     function wpsx_register_taxonomies() {     register_taxonomy('wpsx_language', array (                       0 => 'post',                       1 => 'page',                     ), array(                          'hierarchical' => true,                          'label' => 'Languages',                         'singular_label' => 'Language',                         'show_ui' => true,                         'rewrite' => false,                         )                      );     }     function wpsx_redefine_locale($locale) {         global $post;           if ( taxonomy_exists( 'wpsx_language' )) {             $locale = 'de_DE'; // this does work !!             if ( has_term( 'fr', 'wpsx_language' )) {                 $locale = 'fr_FR'; // this does not work yet :(             }             }          return $locale;     }     add_filter('locale','wpsx_redefine_locale',10);     ?>      So the little part that isn't working is the `has_term()` test. My impression is that the locale filter is running at an early step in the loading sequence, when the post content isn't retrieved yet, and therefore conditional tests like `is_single()` or `has_term()` won't return anything. Can I force the post content to load earlier? Can I delay the locale filter? I'm unable to figure out a solution for this. On the wp-hackers mailing list, a suggestion was to run `global $post;` but this didn't help. * * * **Update:** following the suggestion by david.binda, I found a workaround, dropping the taxonomy, and using the post slug as a trigger:               function wpsx89972_redefine_locale($locale) {         $wpsx_url = $_SERVER['REQUEST_URI'];         $wpsx_url_lang = substr($wpsx_url, -4); // test for the last 4 chars:         if ( $wpsx_url_lang == "-fr/") {             $locale = 'fr_FR';         } else if ( $wpsx_url_lang == "-en/") {              $locale = 'en_US';         } else { // fallback to default             $locale = 'de_DE';          }         return $locale;     }     add_filter('locale','wpsx89972_redefine_locale',10);      This requires the user to rewrite the post slugs, such as "my-post-title-fr" for French, "my-post-title-en" for English, etc. A bit less user-friendly than using language tickboxes, but it keeps the code simple and just works. So now I have a functional multi-language plugin, in only 13 lines of code :) Still, I will leave this question open for a couple days, to see if anyone comes up with a solution that would make use of the taxonomy...


Check for the existence of custom field

I am using the Advanced Custom Fields plugin, and I want to do a query to show all posts where a "date" field is before today and where another custom field (a report) has a value. For now I have this, but I am always getting all past events.                      'post_type' => 'activiteit',        'meta_key' => 'activiteit_datum',        'post_status' => 'publish',        'orderby' => 'meta_value',        'order' => 'DESC',        'meta_query' => array(           'relation' => 'AND',           array( 'key' => 'activiteit_verslag','compare'=>'EXISTS'),           array( 'key' => 'activiteit_datum', 'compare' => '<', 'value' => $fullDate,'type' => 'DATE')             )     );          $pastActivities=query_posts($arg);


Is the object cached?

I have a function to instantiate a class to provide var access to other functions.               function my_data(){     global $post,$the_data;     $postid = get_the_ID();     $the_data = new MY_Class ( $postid );     return $the_data;     }      This function will be called by every post, and each post will call it many times whenever need a var from MY_Class. The data is saved in WordPress postmeta and retrived in My_Class. Does WP automatically cache the object, or should I find a way to cache it? How?


How to change the matches in add_rewrite_rule

One of the examples using `add_rewrite_rule` function in wordpress is               add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=$matches[1]&variety=$matches[2]','top');      I can understand where matches[1] is and where matches[2] is, but is there any way to change these matches, something like:               add_rewrite_rule('^nutrition/([^/]*)/([^/]*)/?','index.php?page_id=12&food=' . f1($matches[1]) . '&variety=' . f2($matches[2]),'top');      Where `f1` is a function of `matches[1]` and `f2` is a function of `matches[2]` Thank you very much. Edit 1: This is a very general question with the objective to understand wordpress add_rewrite rule. One example of f1 and f2 function is               function f1($string) {     if (strpos($string, '/america/')) {$string .= '-1';}     esleif (strpos($string, '/england/')) {$string .= '-2';}     return $string;     }      f2 was a similar function to f1.


How can I customize the search results in Bones theme?

In a site that uses Bones theme, I am trying to localize the search results page and would like to replace the "read more" text with something else. I tried editing the search.php but it is useless as the search.php seems to have a bug (It calls the_excerpt function with parameters while the function does not take any). I also tried the filter hook as described in the function reference but could not make it work, perhaps because I could not call the new function as required. I am quite new to wordpress and php, yes, but I feel there should be an easier way to replace that text. Are there any suggestions?


Get wp_get_attachment_url outside of loop

I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able to get the post ID outside the loop. This is what I've got:               $page_object = get_queried_object();     $page_id     = get_queried_object_id();     $bkgdImg = wp_get_attachment_url( $page_id );     if (!empty($bkgdImg)) {         $backgroundImg = $bkgdImg;     }     else {         $defaultbackground = . get_template_directory_uri() . "/images/default-background.jpg";         $backgroundImg = $defaultBackground;     }          echo $backgroundImg;      Thanks!


wordpress is_main_query() breaks

After upgrading to 3.9 the function `is_main_query()` breaks down and doesn't works the way we want The following code               add_filter( 'pre_get_posts', 'my_get_posts' );     function my_get_posts( $query ) {     echo 'is_main_query: ' . ($query->is_main_query() ? 'y' : 'n');      }      prints 'y' at the top of the page and then keeps on printing 'n' for reasons best known to them.. The actual code which doesnt works               function hwl_home_pagesize( $query ) {          if ( is_home() && $query->is_main_query() ) {              $query->set( 'posts_per_page', 5 );         return;     }                }      add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );      it also breaks the navigation menu of my site


saving/reading custom field value does not work - no value gets POSTed

I am trying to add a custom field to all my posts and of course saving/reading the value. As a starting point I took the example from the Wordpress Codex and stripped it down to bare bones. I know it know has serious security flaws, I am just trying to understand it. The problem I am facing at the moment is that nothing is saved. After looking at what is POSTed when the post is saved, I noticed that the input's key & value is not present in the `$_POST` array at all. The property exists in the database, but without value of course. I also noticed that the variable `$post` passed to the `add_input` is empty, but I don't why (I guess this is the problem?). This is the code from my functions.php:               function add_custom_field() {         add_meta_box( 'my_field', 'My Field', 'add_input', 'post' );     }     add_action( 'add_meta_boxes', 'add_custom_field' );          function add_input( $post ) {         $value = get_post_meta( $post->ID, 'my_key', true );         echo '<input type="text" value="' . $value . '" id="my_id">';     }          function save( $post_id ) {             $mydata = sanitize_text_field( $_POST['my_id'] );         update_post_meta( $post->ID, 'my_key', $mydata );     }     add_action( 'save_post', 'save' );      Do you see any errors in the code above? Do you have any comments to my info I gave you? Why is nothing POSTed to the server?


Uploading non-media files?

I want to add files on WordPress that are non images, embedded video and the like. However when I try this using the upload media feature I get the following error. > "File type does not meet security guidelines." Is there a way to do this using WordPress?


How to intigrate multiple image uploader in a custom post type

![enter image description here](http://i.stack.imgur.com/AaaZP.jpg) How can i add this type of field in the custom post type


WordPress use innodb by default?

I just created a new WordPress site in my server. Normally, WordPress uses MyISAM as the database type. But this time, it created all InnoDB tables! Is this normal? Has WordPress switched to InnoDB in the latest versions?


Display one latest post from multiple categories

This should be very easy, however for some reason I can't find a working snippet anywhere on the web.. I basically need to display one latest post from 6 categories (can be changed to 7,8, etc etc) using one loop. this should be the output: (just a demonstration)

name of category 1
       The title and the permalink of the latest one post from category 1

name of category 2
       The title and the permalink of the latest one post from category 2

name of category 3
       The title and the permalink of the latest one post from category 3
      For now I am using 6 loops using simple query:               <?php query_posts('showposts=1&cat=8'); ?>      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>         //Title, links etc comes her....     <?php endwhile; ?>      But that makes me create 6 loops and I would like to do it easier using **one loop** and a possibility to control how many and which catefories I want to display. Thanks A lot


Excerpts that don't truncate words

I know I can control the length of excerpts using a filter, however it sets the length globally. In my case I have different lengths of excerpts on three different pages. This is what I have now. I'd like to improve it so it doesn't truncate words.               $content_to_excerpt = strip_tags( strip_shortcodes( get_the_content() ) );     $pos = strpos($content_to_excerpt, ' ', 160);     if ($pos !== false) {      echo  "<p>" . substr($content_to_excerpt, 0, $pos) . "...</p>";     }


How to know if I am on 1st page

How can I find out if I am on the 1st page of my home page. I have my page setup like below where I want to display the 1st 2 posts taking up full width. then the rest 1/2. But I want this behaviour on the 1st page only, how can I do that? What condition do I use?


Please Check this '.htaccess' File

I just found my '.htaccess' file has the same lines of code repeated twice as below, maybe some plugins changed it, is it incorrect? Should I remove the repeated one? Thanks!!               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>     # END WordPress


Change CSS on a wordpress post

I want to change the Right-Hand style on the post http://sherridon.bluefrogclients.com/2010/12/15/wellington. Please let me know how to achieve this. Thanks. Sunil.


Am I not understanding plugins?

So I am trying to make it so that you can load a class from a child theme, theme or plugin using the following:               class AisisCore_Loader_AutoLoader{              protected static $_instance;              protected static $_directories;              public function get_instance(){             if(null == self::$_instance){                 self::$_instance = new self();             }                  self::$_directories = array(                 get_template_directory(),                 get_stylesheet_directory(),                 plugin_dir_path(__FILE__),             );                  return self::$_instance;         }              public function reset_instance(){             self::$_instance = null;         }              public function register_auto_loader(){             spl_autoload_register(array($this, 'load_class'));         }              public function load_class($class){             $path = str_replace('_', '/', $class);             foreach(self::$_directories as $directories){                 if(file_exists($directories . '/' . $path . '.php')){                     require_once($directories . '/' . $path . '.php');                 }             }         }        }      But I don't think I am understanding how the `plugin_dir_path` function is working. the problem is that, once this class is instantiated, no class can be loaded in the plugin's directory. that is `/plugin/myplugin/` How ever if I have a theme using the framework I am developing, and the theme is activated, and I instantiate this class in the plugin's main php file via:               //require_once(plugin_dir_path(__FILE__) . 'AisisCore/Loader/AutoLoader.php');     require_once(get_template_directory() . '/AisisCore/Loader/AutoLoader.php');          // Setup the autoloader.     $auto_loader = AisisCore_Loader_AutoLoader::get_instance();     $auto_loader->register_auto_loader();          $obj = new AisisCore_Http_Http();      Then everything works, it sees the AisisCore_Http_http class and and so on, but if I do:               require_once(plugin_dir_path(__FILE__) . 'AisisCore/Loader/AutoLoader.php');     //require_once(get_template_directory() . '/AisisCore/Loader/AutoLoader.php');          // Setup the autoloader.     $auto_loader = AisisCore_Loader_AutoLoader::get_instance();     $auto_loader->register_auto_loader();          $obj = new AisisCore_Http_Http();      it freaks out and cannot find the class. Ideas?


Any way to change the actual filename of an image from media manager?

The default WP media manager does not appear to offer the ability to change an image's filename. Are there any plugins available that allow this functionality?


wp-admin dashboard redirects to homepage

When going to /wp-admin on the website I am working on, it simply goes to the homepage. I then tried going to /wp-login.php and the login screen shows up, but once I login, the url in the address bar says wp-admin, but it still directed me to the homepage. I have indeed gone through the database and changed the siteurl, and I've tried numerous fixes that I've found online, but to no avail. Something odd, though, is that I can access any pages within /wp-admin except for the index. I can go to /wp-admin/edit.php or to /wp-admin/options- general.php, etc... but the moment I click on Dashboard or Dashboard > Home, then I get kicked out of the dashboard and it goes to the homepage, but the url in the address bar still says /wp-admin/index.php ... so, I am at a loss here. Anyone know what the issue could be?


How to make featured image thumbnails on index page load smoother?

I'm using a theme called Hatch Pro, which is a gallery based theme and the index page displays the posts using the featured image. You can see it here. On slower browser environments, the images sort of load in a jumpy manner. In this situation, I'd like them to load with a smoother transition (see example) or preload, so they all are ensured to appear at the same time. The theme author mentioned Lazy Load, but I'm not sure how I would implement that and would welcome any direction. I don't necessarily need them all to load at the same time (as the list of posts will continue to grow), but at least the images being viewed on the screen at the time of loading. I'm comfortable with CSS, but very novice with PHP or other heavier coding.


How do I serve fully cached full HTML on cloudfront

I am using cloud front but want it to serve not just images and CSS but full static HTML pages that are cached locally. I am using wp super cache ... I assume it is caching the full HTML for posts and pages. But I am thinking it would be better to have as much of the site in Cloudfront. I am currently using origin pull, but again it looks like HTML pages as just cached locally. My site doesn't change much it is mostly interviews updated every couple of weeks.


Wordpress display image link in shortcode

I have a shortcode that display an image when you use the image url inside it.               function image_code($atts, $content = null) {         return '';     }     add_shortcode('img', 'image_code');      So when I use the code like this:               [img]https://www.google.com.br/images/srpr/logo3w.png[/img]      it display only the image like this:(in the css I have set the .user-imgs to max-width 600px)                     But I want to display a link to the full image, like this:                     How I can retrieve the image url used in shortcode and use it as a link in to the original image?


Twitter feed - Failed to open stream

This works, however I keep getting a failed to open stream every so many random refreshes/page views. I've also tried this code on two different hosts with the same results. I've also tried using cURL with the same results. It keeps showing an error on the file_get_contents. Is there a conflict with wordpress and file_get_contents?               function get_tweets($twitter_username, $tweet_count) {     if(($twitter_info = file_get_contents('https://api.twitter.com/1/users/show.json?screen_name=' . $twitter_username)) === FALSE) {         return false;     }     $twitter = array();//store all info in this array     if(($profile_info = @json_decode($twitter_info, true)) === FALSE) {         return false;     }     $twitter['name'] = $profile_info['name'];          $tweets = array();          if(($tweets_json = file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name='.$twitter_username.'&count='.$tweet_count))) {         if(($all_tweets = @json_decode($tweets_json, true)) === FALSE) {             return false;         }         foreach($all_tweets as $tw) {             $tweets[] = array('tweet'=>make_clickable_urls($tw['text']), 'created_at'=> 'about '. time_since(strtotime($tw['created_at'])) . ' ago', 'profile_image_url'=>$twitter['profile_image_url']);         }     }     else {         return false;     }     $twitter['tweets'] = $tweets;     return $twitter;     }


Changing wp login url without .htaccess

How to change wordpress login url without using .htaccess, should be a manual process, so `example.com/login` will not redirect to `example.com/wp- login.php` so `example.com/login` will be the login page?