get_locale() behaving strange in same functions.php file

I'm developing a multi-language web portal for my client - in English and Bengali. Instead of using multisite, I installed Polylang plugin. It's working fine through the website. For different CSS styles, and different font-sizes I'm loading a separate stylesheet with:               function styles_and_scripts(){        wp_register_style( 'main-style-bangla', get_template_directory_uri() . '/style-bangla.css', '', '', 'screen' );             // load seperate stylesheet for Bangla        if( get_locale() == 'bn_BD' ) {            wp_enqueue_style( 'main-style-bangla');        }     }          add_action( 'wp_enqueue_scripts', 'styles_and_scripts' );      It's working just fine, and loading different CSS when I'm switching to Bengali. I'm trying the same method for applying filters for Bengali Numerals and Strings etc. with these functions and filters. So I'm doing something like this in my `functions.php`:               if( get_locale() == 'bn_BD' && !is_admin() ) {             add_filter( 'get_the_time', 'make_bangla_number' );             add_filter( 'the_date', 'make_bangla_number' );             add_filter( 'the_time', 'make_bangla_number' );             add_filter( 'get_the_date', 'make_bangla_number' );                  add_filter( 'get_the_time', 'make_bangla_months' );             add_filter( 'the_date', 'make_bangla_months' );             add_filter( 'the_time', 'make_bangla_months' );             add_filter( 'get_the_date', 'make_bangla_months' );     }      But it's not working. I tried to figure out why?               $my_locale = get_locale();     var_dump( $my_locale );      It's returning "`en_US`" in both the languages. You can see the image below for proof: ![enter image description here](http://i.stack.imgur.com/GCRRO.png) Why the same bit of code in the same `functions.php` file is behaving strange in different cases? I then changed the placement of the code just after the enqueue portion, but it's still not working. :( ## UPDATE I found a function from Polylang documentation saying: `<?php pll_current_language($value); ?>` (Source^) will retrieve the current language. I tried `var_dump(pll_current_language());` it returns nothing. Then I managed to find the following code:               function site_current_language() {         global $polylang;         echo $currentLang = pll_current_language('locale');              return $currentLang;     }     //add_action( 'init', 'site_current_language' );  // it does not print     add_action( 'wp', 'site_current_language' );    // it prints      It's working fine, it's echoing the current `$locale`. But instead of echoing this, if I tried returning, it's returning `boolean false`. I tried `global $polylang; var_dump($polylang);` without any function or hook, it's showing that it is failing to find the `curlang` within. But if I do the same inside my style/script enqueue fuction, it's getting the current language. So I suspect there's something related with the proper hook. Note, the hook `init` is failing to echo, but `wp` is echoing. I think we should find a proper hook to get it work. But how, I don't know.


making a plugin that moves other plugins wp_head actions to wp_footer

I am grappling with implimenting jQm on wordpress and have hit the obstacle that most plugins dont work on jQm ajax loaded pages. However, taking the example of the sharethis plugin, I have found that it will run on the ajax loaded page if I change this               add_action('wp_head', 'st_widget_head');      to this               add_action('wp_footer', 'st_widget_head');      in the sharethis.php file The thing is that I want to try and do this leaving the initial plugin files untouched (so that wp updates will work and so that I can keep all my jQm specific plugin modification changes in one place- so they can all be turned off if jQm is turned off) So I think what I n eed to make to begin with is a plugin that loads last, that moves any plugins I specify to move their add_action wp_head to add_action wp_footer. I appreciate this is currently a very brute force solution, but so far this is the only chink of light I have found in what seems to be an impenetrable situation, which otherwise requires re-writing all the plugins I use to work with jQm. So any ideas on this would be very helpful in helping me create a more solid and maintainable solution to this, something like a 'jQm plugin fixer plugin' that I and the community could develop and maintain...


How to remove default style of header in wordpress metabox

I have the problem which when I create a header in my wordpress plugin metabox, it always apply the default style on my header: ![enter image description here](http://i.stack.imgur.com/pwHPk.png) even when I apply, my own style, `<h3 style="background-color: black; color:blue">Text Block Settings</h3>`, it only changes the text color but not the background color, why?? ![enter image description here](http://i.stack.imgur.com/fBRlL.png)


JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly

all right... I am attempting to create a plugin for my site that adds a js snippet to the head section when a front end page loads. The js is meant to add smooth scrolling to all internal links. First off, the plugin does load the script just fine. It's a snippet from: https://github.com/alextrob/SmoothAnchors Everyone else that uses the script seems to think it works great! But I can't get it to work for me. I am VERY new to JS so I wouldn't be surprised if i am doing something really dumb! But, none of the links on my site scroll... Here is my site: http://bigbrownbeaver.net here is the plugin code:               <?php     /*     Plugin Name: Smooth Scrolling Links     Plugin URI: http://bigbrownbeaver.net     Description:Adds a js smooth scrolling effect to all links on your site that point to other parts of a page or post     Version: 1.0     Author: Aaron     Author URI: http://bigbrownbeaver.net/newsletter/     */          /*  Copyright 2013  Aaron > BigBrownBeaver.Net          This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License, version 2, as      published by the Free Software Foundation.          This program is distributed in the hope that it will be useful,     but WITHOUT ANY WARRANTY; without even the implied warranty of     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     GNU General Public License for more details.          You should have received a copy of the GNU General Public License     along with this program; if not, write to the Free Software     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA     */          //load required script                    add_action('wp_head', 'smooth_scrolling_links');          function smooth_scrolling_links() { ?>     <?php if ( !is_admin() ) { ?>              <script type="text/javascript">         (function($) {                 $.fn.smoothscrolling = function() {                          function scrollto(destination, hash) {                              // Change the hash first, then do the scrolling.                         var scrollmem = $(document).scrollTop();                         window.location.hash = hash;                         $(document).scrollTop(scrollmem);                         $("html,body").animate({                             scrollTop: destination                         }, 400);                          }                          if (typeof $().on == "function") {                         $(document).on('click', 'a[href^="#"]', function() {                                  var href = $(this).attr("href");                                  if ($(href).length == 0) {                                      var nameSelector = "[name=" + href.replace("#", "") + "]";                                      if (href == "#") {                                     scrollto(0, href);                                 }                                 else if ($(nameSelector).length != 0) {                                     scrollto($(nameSelector).offset().top, href);                                 }                                 else {                                     // fine, we'll just follow the original link. gosh.                                     window.location = href;                                 }                             }                             else {                                 scrollto($(href).offset().top, href);                             }                             return false;                         });                     }                     else {                         $('a[href^="#"]').click(function() {                             var href = $(this).attr("href");                                  if ($(href).length == 0) {                                      var nameSelector = "[name=" + href.replace("#", "") + "]";                                      if (href == "#") {                                     scrollto(0, href);                                 }                                 else if ($(nameSelector).length != 0) {                                     scrollto($(nameSelector).offset().top, href);                                 }                                 else {                                     // fine, we'll just follow the original link. gosh.                                     window.location = href;                                 }                             }                             else {                                 scrollto($(href).offset().top, href);                             }                             return false;                         });                     }                 };             })(jQuery);                  $(document).ready(function() {                 $().smoothscrolling();             });         </script>     <?php }          }      Love to hear from you guys :)


Registration and Login form

I am creating practice website in which i have "register Here" and "login" link on which I want to open a registration form on click of Register Here and Login Form on click of Login. How can I do this?


How to Remove ALL Widgets from Dashboard?

I'm looking for a complete blank Dashboard. No widgets at all and preferably one column. There are snippets to remove the default WordPress widgets, but haven't found nothing about the ones added by plugins. Searched all over and seems that this hasn't been asked. ![Not blank WordPress Dashboard](http://i.stack.imgur.com/yHfgg.png)


Add custom field automatically (add_post_meta) with value based on number of words of article

In this topic our friend @toscho created a function that sets the font size according to the number of words in the post. Based on this function, I want to create a custom field whose value will be set depending on the number of words in the post. For example, if the post contains up to 200 words, automatically create custom field (add_post_meta) with value = 1; If your post contains more than 200 words, create custom field with value = 2. Any idea is welcome. Thank you.


Pagination shows same contents all pages

Here is my loop                       $my_query = new WP_Query(array(                     'cat' => -399,                     'posts_per_page' => 6,                     'offset' => 5,                     'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1             ));             if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post();                  $imgurl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );                 $finalurl = get_stylesheet_directory_uri(). "/functions/thumb.php?w=180&h=180&a=t&src=".$imgurl;                 $date = get_the_date();                  $id = $post->ID;             ?>             .... loop contents ....                  <?php $finalurl = "";             endwhile;             else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
             <?php endif; wp_reset_query();             $id = ""; wp_pagenavi();      Pagination shows same content in all pages. I need your suggestion.


Add file extension to temporary file

I am using download_url() to download a temporary file and want to save this file in my uploads folder using media_handle_sideload. This works fine with files that have a file extension. media_handle_sideload dosent work with files that have no file extension. So when im trying to save for example this image it wont save, because the url has no file extension. Then I need to use `image_type_to_extension(exif_imagetype($imageurl));` to get the file extension for the image. How can I add this file extension to the temporary file? here is my code:               public function upload_image_from_url($imageurl) {                  // Get the file extension for the image             $fileextension = image_type_to_extension(exif_imagetype($imageurl));                  // Save as a temporary file             $tmp = download_url( $imageurl );                  $file_array = array(                 'name' => basename( $imageurl ),                 'tmp_name' => $tmp             );                  // Check for download errors             if ( is_wp_error( $tmp ) ) {                 @unlink( $file_array[ 'tmp_name' ] );                 return $tmp;             }                  $id = media_handle_sideload( $file_array, 0 );             // Check for handle sideload errors.             if ( is_wp_error( $id ) ) {                 @unlink( $file_array['tmp_name'] );                 return $id;             }                  $attachment_url = wp_get_attachment_url( $id );                       return $attachment_url;          }          Thanks.


the_author_meta('user_url', $author->ID) not working properly. how can I solve this?

I have 2 authors and an admin on my blog. I am using the following code in my contributors.php               function contributors() {             global $wpdb;                  $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");                  foreach($authors as $author) {                  echo the_author_image($author->ID);                  echo the_author_meta('display_name', $author->ID) . '
' ;             echo the_author_meta('user_url', $author->ID) . '
';             echo the_author_meta('description', $author->ID) . '
' ;             echo the_author_meta('user_email', $author->ID) . '

' ;                  }             }                  contributors();      It's printing all authors' and admin's photo, name, description and email perfectly. but it not printing the user link correctly.   * for admin or user ID 1 it's printing the blog URL   * for 1st author or user ID 2, it's printing the correct URL.   * for 2nd author or user ID 3, it's printing nothing. what is the problem? how can I solve this?


sort by vote with GD STAR RATING plugin

Does anyone have any suggestions as to how I can get the sort by vote count to work with the GD STAR RATING plugin? I have added sorting parameters to a category list on my site but it still isn't ordering the posts by the number of thumbs up votes. http://uhurusoftware.com/category/contest/?gdsr_sort=votes&gdsr_order=asc Does anyone have suggestions of what I should check? Are there options I need to set in the GD STAR RATING admin panel?


Query posts by Custom Meta (checkbox) & Genesis Grid Loop

I've been trying tons of things for the last 2 days. I'm at a standstill now. I read a ton of posts here but nothing has worked yet. I have a CPT 'artists'. This CPT contains a custom field checkbox called Featured Artists 'ecpt_featured_artist'. Within the Genesis Grid Loop on the Artists archive page 'artists-archive.php' I am able to target the Featured Artist like this:               $featuredartist = get_post_meta($post->ID, 'ecpt_featured_artist', true); ?>     <?php if( $featuredartist ) {         echo '

';     }      I'm currently using Bill Erickson's code to put the artists-archive in a grid... like this:                   function be_archive_post_class( $classes ) {         $classes[] = 'one-fourth';         global $wp_query;         if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 4 )             $classes[] = 'first';         return $classes;     }     add_filter( 'post_class', 'be_archive_post_class' );      **What i'm trying to accomplish:** I want to query ONLY post with the checkbox checked, and display them in the Genesis Grid, on a page called Featured Artists. Right now i'm attempting to do that via a page template. If there is a better way altogether to accomplish this, I'm open to suggestions. Right now, I can't even query the posts properly. My last failed attempt looked like this:               add_action('genesis_loop', 'gt_custom_loop');     function gt_custom_loop() {     global $paged;              $args = array(         'post_type' => 'artists',         'key' => 'ecpt_featured_artist',         'compare' => '=',         'type' => 'CHAR',         'value' => 1,         );         // Accepts WP_Query args          // (http://codex.wordpress.org/Class_Reference/WP_Query)         genesis_custom_loop( $args );          }      Any help appreciated! EDIT: I've reduced it down to minimal code ONLY in my functions.php file, with the page using the default page template. This code now 404's me on my 'page' Featured Artists:               add_action( 'pre_get_posts', 'pw_filter_query' );     function pw_filter_query ( $query ) {         if( $query->is_page('featured-artists')) {         $query->set('post_type', 'artists');         }        }      What is going on!?


Why can't I use an array of term slugs in WP_Query?

In `WP_Query`, a comma-separated list of term slugs works fine:               $query = new WP_Query ( array(            'customtaxonomy' => 'term1,term2'     ) );      ...but an array of slugs causes a warning:               $query = new WP_Query ( array(            'customtaxonomy' => array( 'term1', 'term2' )     ) );      > **Warning:** urlencode() expects parameter 1 to be string, array given in > /path/to/wp-includes/formatting.php on line 3253 Another WPSE post proposes that this could be WP looking for hierarchy in a hierarchical taxonomy, but I can't think of any way to make sense of this behaviour. Do you know why this is happening?


How brute-forcer knows that the password is cracked for target username?

There are very many brute-force attacks (mostly for 'admin' username) on WordPress sites. All these attacks are made automatically via post requests. _The question 1:_ **how brute-forcer knows that the password is cracked for target username?** The brute-forcer try the typical passwords like: '12345', 'qwerty' etc. And often site administrators have username 'admin' with typical password and this username is cracked sometimes via brute-force. Limit-login attempts plugin solve this problem pretty good by the way. _The idea and question 2:_ if we know for sure that it is brute-force attack (javascript-test or cookie-test solve this because brute-force-bots are not usual browser clients) than **is it good approach to tell brute-forcer nothing at all even if the password chosen correctly?** Discussion on WordPress.org forum. Update: **I developedSecurity-protection plugin**. Plugin adds cookie on login screen and checks if this cookie exists in the POST request. If cookie does not exist than it is brute-force request and the login attempt is blocked even if username and password are correct. Plugin sends fake WordPress login cookies to the brute-force bot and redirects it to the admin section to emulate that the password is cracked and many brute-forcers stop their attacks after this. It is really awesome :)


How to let user select role upon registration in Facebook-AWD?

I would like to use the plugin Facebook-AWD plugin. My site would provide two ways of registration (normal and register with Facebook). Users must select their role, ie: _buyer_ and _seller_. With normal registration, I can achieve this easily but if my users choose to register with Facebook-AWD they can't select between roles as the plugin is set up to register user with default role:               'role'=>get_option('default_role');      How can achieve this by adding a hook or action or filter to the plugin in order to preserve the plugin core for future update?               public function register_user()     {         $username = sanitize_user($this->me['first_name'], true);         $i = '';         while (username_exists($username . $i)) {             $i = absint($i);             $i++;         }         $username = $username . $i;         $userdata = array(             'user_pass' => wp_generate_password(),              'user_login' => $username,              'user_nicename' => $username,              'user_email' => $this->me['email'],              'display_name' => $this->me['name'],              'nickname' => $username,              'first_name' => $this->me['first_name'],              'last_name' => $this->me['last_name'],              'role' => get_option('default_role')         );         $userdata = apply_filters('AWD_facebook_register_userdata', $userdata);         $new_user = wp_insert_user($userdata);         //Test the creation                                  if (isset($new_user->errors)) {             wp_die($this->Debug($new_user->errors));         }         if (is_int($new_user)) {             //send email new registration             wp_new_user_notification($new_user, $userdata['user_pass']);             return $new_user;         }              return false;     }


Why is my footer missing

Hi for some reason my footer is missing on my site, and i don't know why. I have deactivated all plugins and it's still not there, I have checked the css and all, but the footer is still missing can someone tell me whats wrong. When I view the Source Code the Footer is there but It's not showing up. The Site is EricaVain.com Here are the files on gist --> https://gist.github.com/mihadaiko/5008645


Load Paginated Comments Inline

Currently my WordPress blog loads the comments in paginated results (loading all at once slowed down the blog too much); first displaying the oldest 50, after clicking "<< Older Comments" it will display the next 50 oldest comments and so on. I would like these comments to load inline with the current comments eliminating the need to load a new page and hide the first 50 comments. For clarity: I am not looking to infinite scroll the comments, I would still like the user to have to click on the "Older Comments" text in order to view more comments.


set_post_thumbnail_size vs add_image_size

What is the difference between set_post_thumbnail_size and add_image_size? Is set_post_thumbnail_size for all images, and add_image_size for sizing images individually? Thanks.


Mixing Custom Post Types and Page Templates in Wordpress 3.7.1

### Overview I have a Custom Post Type called Locations. When the user visits **/locations** , I would like them to see some general information about all the locations. When the user visits **/location/{a-location}** , I would like them to see specific information about "a-location". Sounds easy enough. ### 1st Solution Attempt I created a Locations page in the Wordpress dashboard to hold the content for the /locations url. I then created an archive-locations.php file and a single- location.php. archive-locations.php pulls info out of the Locations page and it lists all of the custom post type Locations. When the user clicks on a link for a location, the user gets redirected to /locations/{a-location} and single-location.php gets called. This almost does the trick, but it just doesn't feel right and it's creating some other problems. ### The Problem When a user visits /locations I would prefer to be working with a page template for the Locations page (instead of the archive-locations.php page). I'm using the Yoast plugin to specify a custom meta title and description for each page. Since archive-locations.php is being used, all of this meta gets ignored. If I were working with a page template, my meta info would get recognized correctly. Also, logically, it feels like I should be working on the Locations PAGE, not an archive. The Locations PAGE is it's own entity with much more content then just an archive of custom post types. To try and force it into an archive concept seems like a stretch. ### 2nd Solution Attempt So I created a page-locations.php template for the Locations page and I was hoping that it would get called instead of the archive-locations.php. Unfortunately, it does not. I then tried removing the archive-locations.php thinking that maybe it was taking precedence. That didn't help either; Wordpress simply renders index.php. If I disable the Custom Post type and visit /locations, then my page template is called correctly. It looks like naming a custom post type the same name as a page causes Wordpress some issues. However, I need to be somewhat similar for the URL structures to work out. /locations needs to pull from a page template; /locations/{a-location} needs to pull from another php file. ### Question Is there any way to get page templates and custom post types with similar permalinks to work together? If not, I guess my only option is to enhance my header.php and be smarter about determining the title and description when I'm on /locations. Here's the code that registers my custom post type in case I'm doing something wrong:               $args = array(         'labels'        => $labels,         'description'   => 'Holds our location specific data',         'public'        => true,         'menu_position' => 20,         'supports'      => array('title', 'editor', 'thumbnail', 'page-attributes' ),         'hierarchical'  => true,         'has_archive'   => true,         'rewrite'       => array('with_front' => false, 'slug' => 'locations') //remove /news/ from the permalink when displaying a custom post type     );     register_post_type( 'locations', $args );      (I also tried changing has_archive to false, but it didn't help.)


4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter

I found some code for creating multi-column WordPress loops and I found some code for entries grouped by letter of the alphabet. But I can't quite get the code to work together...the order is a bit messed up. EXAMPLE http://52words.org/w/ I would appreciate some assistance.                         <?php     $num_cols = 4; // set the number of columns here     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination     $args = array(       'orderby' => 'title',       'order' => 'ASC',        'posts_per_page' => '199',       'paged' => $paged,       'post_type' => 'wiki'       );     query_posts($args);     //end of query section     if (have_posts()) :       for ( $i=1 ; $i <= $num_cols; $i++ ) :         echo '
';         $counter = $num_cols + 1 - $i;         while (have_posts()) : the_post();           if( $counter%$num_cols == 0 ) : ?>                  <?php              $title=get_the_title();              $initial=strtoupper(substr($title,0,1));             if($initial!=$letter)               {               echo "
$initial

";               $letter=$initial;               }              { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ); ?> <?php the_title_attribute(); ?>"><?php the_title(); ?>
          <?php }   ?>                <?php endif;           $counter++;         endwhile;         rewind_posts();         echo '

'; //closes the column div       endfor; ?>


Add Filter - Pass Variable (PHP < 5.3)

When using Anonymous Functions in PHP < 5.3 I get this error: `Parse error: syntax error, unexpected T_FUNCTION` This is especially troublesome for add_filters. For instance, if I want to make a filter for a custom excerpt **The Function**               function custom_excerpt($new_length = 20, $new_more = '...', $strip = false) {         add_filter('excerpt_length', function () use ($new_length) {             return $new_length;         }, 999);         add_filter('excerpt_more', function () use ($new_more) {             return $new_more;         });         $output = get_the_excerpt();         $output = apply_filters('wptexturize', $output);         $output = apply_filters('convert_chars', $output);         if(!$strip)             $output = '<p>' . $output . '</p>';         echo $output;     }      The function above accepts 3 parameters, lenth, read more, strip. You pass this function a new length such as '30' and it will give me an post excerpt of 30 words. The read more will replace the default `[...]` with the functions default `...`. The point of this is to use `the_excerpt()` and change the amount of words and remove the `[...]` My question now is how can I pass my `$new_length` variable to this filter in PHP < 5.3?


Custom filter for main search: how to exclude specific post_type from search results

Is there a way to use WP_Query's method, set(), in order to exclude a specific post_type from a global search. Here was my unsuccessful attempt:               function _search_all($query) {       if($query->is_search()) {                 // get rid of in the news                 $query->set('post_type__not_in', array(IN_THE_NEWS_SLUG));              if(isset($_GET['post_type'])) {             $query->set('post_type', $_GET['post_type']);         } /*else {             $query->set("post_type", array(FEATURES_ID, BRIEFS_ID, PRESS_RELEASES_ID));         }*/     }     return $query;     }     add_filter("pre_get_posts", "_search_all");


Creating distinct pages for author profiles and lists of posts by author

The site I'm currently working on includes profile pages for each author plus a method to search for posts by a specific author. So we would have a page at `/author/author-name/` that only displays a list of posts by that author and a page at something like `/author/author-name/profile/` that shows extended user info but no posts. By default Wordpress includes an `author.php` template that shows some basic user info and recent posts by the author. This is found at `/author/author- name/`. When looking for recommended ways to build a user profile, everything I have found recommends altering this file and using the same URL, however we would like to use both. The only way I can think of achieving this would be to allow the page to take a parameter so that `/author/author-name/?profile=1`, rewrite it in `.htaccess` so that it appears as `/author/author-name/profile/`. Then alter `author.php` to check for this parameter and use a separate template. I would like to avoid methods such as this and stay on the Wordpress rails as much as possible. Are there any plugins or other Wordpress approved methods I could use to solve this problem? (We're running 3.8 by the way).


WordPress Blog RSS Feed?

Actually I want to Add My WordPress Blog To **CodeProject** Article List for That I need Rss Feed so Whenever I Post Any Article On My Blog It Will Automatically Listed on CodeProject As Well. I want to Know **WordPress** Blog **RSS Feed** but dont know any thing about it, Help Will Be Appreciated..


Cron jobs for deactivated plugins

Hi I am using a plugin to view the cron jobs that are run by wordpress. I am noticing that there are jobs related to plugins I have deactivated and even deleted. Why is this so and how can I remove them?


Direct iPhone visitors to different stylesheet?

Is there a method whereby I can employ a different stylesheet (different to the style.css in my child theme) to visitors viewing on the iPhone?


Using filter in the widget causes fatal error

I'm adding a filter for a WordPress query in a widget. I'm adding as following:               function filter_where( $where = '' ) {          }     add_filter( 'posts_where', 'filter_where' );     $query = new WP_Query( $args );     remove_filter( 'posts_where', 'filter_where' );      It works fine, but if I use the same widget more than 1 times then I get the fatal error that the same filter cannot be re-declared. How can I use the filter so that the same widget can be used multiple times? This is the exact error I get:               Fatal error: Cannot redeclare filter_where() (previously declared in xxx.php:70)      Thanks.


Deleting sites and users automatically in multisite

I am trying to create a scheduled delete of sites and their users in WordPress multisite. The code I made is successful in deleting the sites but not the users, can anyone offer a fix?               <?php     register_activation_hook( __FILE__, 'wpchat_clear_sites_activation' );     /**      * On activation, set a time, frequency and name of an action hook to be scheduled.      */     function wpchat_clear_sites_activation() {         wp_schedule_event( 1386979200, 'daily', 'daily_clear_sites_hook' );     }               add_action( 'daily_clear_sites_hook', 'wpchat_clear_out_sites_daily' );     /**      * Clear out the sites and users      */     function wpchat_clear_out_sites_daily() {          require_once( ABSPATH . 'wp-admin/includes/admin.php' );         require_once( ABSPATH . 'wp-admin/includes/user.php' );              if( ! function_exists( 'wpmu_delete_blog' ) ) return;                  $users_to_keep = array( '1','4','43' );              $blogs_to_keep = array( '1','4' );              $all_sites = wp_get_sites();                  // Remove all blogs except for the main blog and the template blog         foreach ( $all_sites as $key => $val ) {                  $users = get_users( array( 'blog_id' => $val['blog_id'], 'fields' => ID ) );                  // Remove all users except for the test site admins             foreach ( $users as $user) {                       if ( ! in_array( $user['ID'], $users_to_keep ) ) {                     wpmu_delete_user( $user['ID'] );                 }             }                  if ( ! in_array( $val['blog_id'], $blogs_to_keep ) ) {                 wpmu_delete_blog( $val['blog_id'], true );                       }              }     }      The sites are deleted via cron or via direct function call, so cron is not the issue here, it's the way I'm trying to delete users.


Syling Custom Fields echo's from from functions.php

With the help of User Borek I've managed to get Custom Fields displaying on my siteby putting the below in the functions.php:               function custom_field_before_content() {     if(is_page() || is_single() || is_archive() ) {         echo genesis_get_custom_field('instrument');}     }     add_action( 'genesis_entry_header', 'custom_field_before_content' );      I'm having trouble putting an id or class on them though so I can style them. I am using a Genesis theme and I can't figure out how to do this. I have tried following this tutorial with no success. Does anyone know where I can put an id or class on these custom fields in a genesis theme? This is one of the pages where my custom fields are displaying: http://bethlehem-music.org/?p=18. Right above the image and under the title. Appreciate any help, Ciarán


How to prevent a function from running based on host (ie web vs local)?

I am using LiveReload to refresh my browser and compile my SASS. The browser extensions are not working so well for me, so I am adding the script to my footer. I'm trying to think of a way to prevent the function that adds it from running if it is on a live web server opposed to my local production environment XAMPP (in OSX 10.6.8). This is what I have now:               if (! function_exists('_sf_live_reload') && ! is_admin() ) :     function _sf_live_reload() { ?>     <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>     <?php      }     add_action('tha_body_bottom', '_sf_live_reload');     endif;      Yes, I know I could just remember to manually delete it before uploading, but lets assume I forge things from time to time. Plus deleting and recreating this over and over again isn't the best solution anyway.


HTTP Error when uploading images over specific dimensions

Hello I have a reseller account with one wp 3.5 multisite on a shared hosting. Suddenly I can't upload photos after some random dimensions(It uploads the small sized ones just fine, but it has problems with the bigger ones).Specific any photo over than 511(width) i got http error , and any image less than 511(width) upload without any http error **Operating System :** Linux (64 Bit) **Server:** LiteSpeed **Apache version:** 2.2.23 **Entry Processes:** 20 **Virtual Memory Usage & Physical Memory Usage:** 1048576 KB (each) **I/O Usage:** 1024 KB/s **My PHP specs:**   * **PHP Version:** 5.3.18   * **mysql Client API version:** 5.1.65-cll   * **post_max_size** 60m (Local Value) - 60m (Master Value)   * **upload_max_filesize** 100m (Local Value) - 200m (Master Value)   * **memory_limit** 1024m (Local Value) - 1024m (Master Value)   * **max_input_time** 60 (Local Value) - 60 (Master Value)   * **max_execution_time** 3600 (Local Value) - 600 (Master Value) **functions.php of my theme:** http://pastebin.com/ddEQqVJy My multisite .htaccess is                   # BASIC SECURITY        <IfModule mod_security.c>        <Files async-upload.php>         SecFilterEngine Off         SecFilterScanPOST Off         </Files>         </IfModule>         #<IfModule mod_security.c>         #SecFilterEngine Off         #SecFilterScanPOST Off         #</IfModule>         php_value memory_limit 1024M         php_value max_execution_time 3600         php_value post_max_size 60M         php_value upload_max_filesize 100M         </IfModule>         #php_value memory_limit 128M         #php_admin_flag safe_mode off         # Prevent folder browsing         Options All -Indexes              <Files wp-config.php>         order allow,deny         deny from all         </Files>              # BEGIN feedburner and uploaded files adjustments.         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]         RewriteRule ^feed/?.*$ http://feeds.feedburner.com/mysite [L,NC,R=302]         RewriteRule ^home?.*$ http://feeds.feedburner.com/mysite [L,NC,R=301]         RewriteRule ^wp-content/uploads/(.*)$ http://mysite.com/files/$1 [L,R=301]         RewriteRule ^wp-content/gallery/(.*)$ http://mysite.com/files/$1 [L,R=301]         RewriteRule ^wp-content/uploads/jw-player-plugin-for-wordpress/player/player.swf$ http://mysite.com/files/jw-player-plugin-for-wordpress/player/player.swf$1 [L,R=301]         </IfModule>              # BEGIN ANTISPAMBLOG REGISTRATION         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{REQUEST_METHOD} POST         RewriteCond %{REQUEST_URI} .wp-signup.php*         RewriteCond %{HTTP_REFERER} !.mysite.com. [OR]         RewriteCond %{HTTP_USER_AGENT} ^$         RewriteRule (.*) http://die-spammers.com/ [R=301,L]              RewriteCond %{REQUEST_METHOD} POST         RewriteCond %{REQUEST_URI} .wp-comments-post.php*         RewriteCond %{HTTP_REFERER} !.*mysite.com.* [OR]         RewriteCond %{HTTP_USER_AGENT} ^$         RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]         </IfModule>              # BEGIN Watermark Hotlinked Images         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteCond %{HTTP_REFERER} !^$         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?mysite.com  [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?facebook.com [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?twitter.com [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?yahoo.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?bing.\ [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?ixquick.com  [NC]         RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?feeds.feedburner.com/mysite  [NC]         RewriteRule ^(.*\.(png|gif|jpe?g))$ http://mysite.com/wp-content/plugins/watermark-hotlinked-images/watermark.php?img=$1 [L]         </IfModule>              # END Watermark Hotlinked Images              #Begin gzip and deflate         <IfModule mod_deflate.c>          AddOutputFilterByType DEFLATE text/html text/css application/x-javascript text/plain text/xml image/x-icon         </IfModule>         <IfModule mod_expires.c>         ExpiresActive On         ExpiresByType text/html M3600         ExpiresByType text/css M3600         ExpiresByType application/x-javascript M3600         ExpiresByType image/bmp M3600         ExpiresByType image/gif M3600         ExpiresByType image/x-icon M3600         ExpiresByType image/jpeg M3600         </IfModule>              # BEGIN WordPress         RewriteEngine On         RewriteBase /         RewriteRule ^index.php$ - [L]              # uploaded files         RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]              RewriteCond %{REQUEST_FILENAME} -f [OR]         RewriteCond %{REQUEST_FILENAME} -d         RewriteRule ^ - [L]         RewriteRule . index.php [L]         #END WordPress      Update: This is my functions.php of my theme http://pastebin.com/ddEQqVJy We find the problem , the problem is on line 131               add_image_size('theme-thumb', 520, 497, true);      lines 267-275               if (function_exists('add_theme_support')) {         add_theme_support('post-thumbnails');         set_post_thumbnail_size(150, 250); // default Post Thumbnail dimensions     }          if (function_exists('add_image_size')) {         add_image_size('post-thumb', 310, 9999); //300 pixels wide (and unlimited height)         add_image_size('widget-thumb', 220, 180, true); //(cropped)     }      When we took them off it didn't show any "HTTP error" when we uploaded a photo on media. on function.php of Twenty Twelve use               // This theme uses a custom image size for featured images, displayed on "standard" posts.         add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop      without giving any "HTTP error" is strange, do you know why is this happening? And how can I fix it?


How to track hits of a single media file?

I have multiple media files in my WordPress Media Library. Icons, Images, PDF's and the like. I would like to have a stat counter, that gives me a statistic of the downloads/hits of those files, individually. **I already use WP SlimStat** to track page view, and I am quite happy with it. However, **I have not found a possibility to track those media files.** How can I do this?


Moving a WP Multisite to a subdirectory

Firstly, I've read a number of posts on this process. However, for various reasons, the process remains difficult to implement or troubleshoot for lack of even abstracted examples, or maybe too abstracted. And there's a few "can not do" posts, nearly always followed up by "with 3.5, you now can" caveats, so whether one can remains ambiguous, though no doubt non-trivial. ## Summary: How to move a wordpress multisite (WPMS) from root.com to root/blogs? For this example, we're moving a WPMS from "root.com" to "root.com/blogs" I understand that I need to update the paths in the database and wp-config.php appropriately. It seems I may also have to update .htaccess? I'm also aware of the serialization issue with search/replace and mysql query updates. I have a WPMS that I've updated to 3.5. I've found the following tables with domain and path info ## Existing working configuration before move to subdirectory ### 1. wp_blogs               select blog_id, domain, path from wp_blogs;     +---------+-------------+--------+     | blog_id | domain      | path   |     +---------+-------------+--------+     |       1 | root.com    | /      |     |       2 | root.com    | /matt/ |     +---------+-------------+--------+      ### 2. wp_site               select * in wp_site;     +----+-------------+------+     | id | domain      | path |     +----+-------------+------+     |  1 | root.com    | /    |     +----+-------------+------+      ### 3. The blog_id corresponds to the wp_#_options tables which contain:               select option_name,option_value from wp_2_options      where option_name = 'home' or option_name = 'siteurl';     +-------------+--------------------------+     | option_name | option_value             |     +-------------+--------------------------+     | home        | http://root.com/matt/    |     | siteurl     | http://root.com/matt/    |     +-------------+--------------------------+      ### 4. In my **wp-config.php** I have the following WPMS-specific lines:               define('WP_ALLOW_MULTISITE', true);     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false);     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'root.com' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      ### 5. Lastly, in my **.htaccess** , I have:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      ## Updates required to move the site It seems to me that in order to move my site to the /blogs , I would: ### 1. Update wp_blogs to               mysql> update wp_blogs set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');     select blog_id, domain, path from wp_blogs where blog_id < 3;     +---------+-------------+--------------+     | blog_id | domain      | path         |     +---------+-------------+--------------+     |       1 | root.com    | /blogs/      |     |       2 | root.com    | /blogs/matt/ |     +---------+-------------+--------------+      ### 2. Update wp_site to               update wp_site set domain=concat(domain, '/blogs'), path=concat(path, 'blogs/');     select * from  wp_site;     +----+-------------+------------+     | id | domain      | path       |     +----+-------------+------------+     |  1 | root.com    | /blogs/    |     +----+-------------+------------+      ### 3. wp_#_options               +-------------+--------------------------------+     | option_name | option_value                   |     +-------------+--------------------------------+     | home        | http://root.com/blogs/matt/    |     | siteurl     | http://root.com/blogs/matt/    |     +-------------+--------------------------------+      ### 4. wp_config.php               define('WP_ALLOW_MULTISITE', true);     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false);     $base = '/blogs/';     define( 'DOMAIN_CURRENT_SITE', 'root.com' );     define( 'PATH_CURRENT_SITE', '/blogs/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      **note:** I'm not clear how this step is appropriately updated ### 5. .htaccess I found vague "update .htaccess appropriately" instructions, but not specifics. Update RewriteBase? Which lines in .htaccess to I update when I move root.com to root.com/blogs? Missing from the above process will be the paths founds in posts. My druthers are to use the search and replace tool for that, after I've made this more fundamental updates; or am I wrong? _Update_ bungeshea suggests that, yes, I point RewriteBase to the "blogs" subdirectory, i.e.,               RewriteBase /Blogs      Finally, if you don't know about http://interconnectit.com/products/search- and-replace-for-wordpress-databases/ you should. It's excellent.


Taxonomy + post_type

I'm quite lost with taxonomies and custom post type.   * I have a taxonomy -> auteur    * I have custom_post-type -> citation (quote in french). I just want list all citations (quote) from an auteur (auteur = taxonomy) with a permalink structure like this :               www.myblogname.com/citation/auteur_name/      or               www.myblogname.com/auteur_name/citation/      or               www.myblogname.com/auteur/auteur_name/citation/      ( in fact the easiest way). what are the steps to do this job (and what is the template page to modify).


Category based on post id

I have the following:               $custom_loop = new WP_Query( array('category_name'=>$category, 'meta_key'=>'name', 'orderby' => 'meta_value', 'order' => 'ASC', 'posts_per_page'=>'-1'));      How can I tell it that if `$post->ID == 1` then `$category == 'first'` and if `$post->ID == 2` then `$category == 'second'` I suppose it should be an array of some sort, but I just can't figure out what?


creating a static HTML/JS/PHP page

i need to create a static page that allows me to code HTML/JS/PHP that connects to a separate MYSQL backend. how can i achieve such in wordpress page?


Setting name of attachment URL

I have a problem I need to fix with the URLs that are generated for the attachment pages of images with metadata. I’m working on a photography site where individual photos are displayed as attachments to a post, via `attachment.php`. The URL scheme for displaying these photos is something like this: `domain.com/project-name/attachment/attachment-name`. If I upload an image without any metadata, then the last part of the attachment URL is taken from the file name of the image. So, if the image is `ABCD.jpg`, then the URL is `domain.com/project-name/attachment/ABCD`. All good. However, if the image _does_ have a title in the metadata, then the URL is set to that title: `domain.com/project-name/attachment/omg-cool-photo`. Is it possible to have a metadata title with a photo, but to also have the URL that is set for the attachment to remain as the photo filename? If so, how? I took a look around but I couldn’t see anything about this here already. Sorry if it is and I missed it. Any help gratefully received! Thanks.


Posts with no meta field do not appear when sorting by meta field

I want to order my posts by a custom meta field "fieldA". I am using the following code:               $query->set( 'meta_key', 'fieldA);     $query->set( 'orderby', 'meta_value_num' );     $query->set( 'order', 'DESC' );      Ordering works fine but there is a problem. All posts which do not have the meta_key "fieldA" are not fetched. Any idea what's wrong? thx


What is the most efficient way of adding additional functionaliy for admin only

I'm trying to figure out the best approach to add additional functionality that will only be utilized by admins via /wp-admin. What's the best way to implement so that resources aren't being wasted. I.E. if statement each page load or any other code execution on each page load for areas not even pertaining to the dashboard. Thanks.


Comments orderby comment date not working

I have a template to get the comment replies to a user and display it on a static page. It works reasonably well in so far as the correct comments are displayed but whatever I try I can't get the replies to order by comment date, the newest first, but instead they will order by their parent comment first and after that by date. Also, the pagination is not displaying. I would be most grateful for any help or hints here!               <?php      global $current_user;     get_currentuserinfo();     define('DEFAULT_COMMENTS_PER_PAGE',6);     $page = (get_query_var('page')) ? get_query_var('page') : 1;     $limit = DEFAULT_COMMENTS_PER_PAGE;     $offset = ($page * $limit) - $limit;     $param = array(         'status'=>'approve',         'user_id' => $current_user->ID,         'comment_parent' => 0     );     $parent_comments = get_comments($param); ?>     <?php foreach($parent_comments as $parent_comment) : ?>     <?php $parent_comment_id = $parent_comment->comment_ID;     $comment_args = array(         'orderby' => 'comment_date',         'status' => 'approve',         'parent' => (int)$parent_comment_id,         'offset' => $offset,         'number' => $limit     );     $comments_query = new WP_Comment_Query;     $comments = $comments_query->query( $comment_args );     if ( $comments ) : ?>         <?php foreach($comments as $reply) : ?>
             <?php echo $reply->comment_author; ?>has left a                 <a href="<?php echo get_comment_link( $reply->comment_ID ); ?>">reply to your <a href="<?php echo get_comment_link( $parent_comment->comment_ID ); ?>">comment
                 <?php echo apply_filters('the_content', $reply->comment_content); ?>

         <?php endforeach; ?>     <?php endif; ?>     <?php endforeach; ?>
          <?php $pages = ceil(count($comments)/DEFAULT_COMMENTS_PER_PAGE); ?>          <?php     $args = array(         'base' => 'http://mywordpress.example/user/replies/%#%',         'format' => '?page=%#%',         'total' => $pages,         'current' => $page,         'show_all' => False,         'end_size' => 1,         'mid_size' => 2,         'prev_next' => True,         'prev_text' => __('Previous'),         'next_text' => __('Next'),         'type' => 'plain');           echo paginate_links( $args );     ?>


get_queried_object() returns null on post date archive

`get_queried_object()` returns `null` on post date archives (page type `is_date()`) and the main blog index page (page type `is_home()`). Is this intentional, or just an oversight? I was writing a wrapper around get_queried_object() to get the title of the current page, no matter what type of page it is, for use in a theme. I quickly realized that instead of using `get_query_object()` I should just duplicate the important bits from `wp_title()`, but before that I came across an interesting issue. It appears that `get_queried_object()` and its root function `WP_Query->get_queried_object()` return `null` for a couple of listing types, including the primary posts list output by index.php (page type `is_home()`) and post archives by date (page type `is_date()`). I tested this by throwing the following snippet into a number of template files in a number of locations, always after `get_header()` and before `the_post()`:
<?php         $queried_object = get_queried_object();         var_dump( $queried_object );     ?>
      This works perfectly on category archives, tag archives, custom taxonomy archives, and custom post type archives. `get_queried_object()` returns the query object, which can be used to extract a page title and other useful information. However, it fails in archive.php for standard post date archives and index.php for the normal blog posts home page list view. Digging into the source of `WP_Query->get_queried_object()` reveals something rather unsurprising: there is no check for page type `is_home()` or page type `is_date()`, so on those page types `$this->queried_object = null;` is not updated and the function returns `null`. So my question is, is this intended functionality (e.g. are you not supposed to use get_queried_object() on those pages), a technical limitation (is there not a meaningful object to return on those pages), or simply an implementation oversight? Is there even an equivalent of the custom post type object for the built-in "blog post" post type to display?


How to Create Editable Blocks of Text for the Homepage?

I'm making a site based on WordPress. It's not going to seem a blog or WP. Just a website. So WP acts like backend where the client can edit the text blocks. Question:   * How can I put block of text on my designed template wich users can edit from admin panel? Let's say something like this: ![homepage wireframe](http://i.stack.imgur.com/i1mku.png) The 3 top blocks (about us, mission, why us...), how do you fill them from admin panel? Or specific text from header or footer. Do I have to create 3 posts, and reference them on template through `get_post($id)`? Which is the best way to do it?


Selectbox Custom Post Type

I use a dropdownbox to show all custom types. On the archive page of the custom post type it works fine. If I put dropdownbox to another site, it doesn´t work anymore. The selectbox is empty. Any ideas?                 <input type="text" class="text-input" placeholder="Nutzungsdauer" value="" name="nutzungsdauer" id="nd">      function.php               function afa_type_dropdown( $post_type )     {     $posts = get_posts(     array(         'post_type'  => $post_type,         'numberposts' => -1     )     );     if( ! $posts ) return;          $out = '<select id="afa_select"><option>Anlagegut auswählen</option>';     foreach( $posts as $p )     {     $out .= '<option value="' . get_permalink( $p ) . '">' . esc_html( $p->post_title ) . '</option>';       }     $out .= '</select>';     return $out;     }


add_filter and changing output captions of image gallery

I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine (link) author advises to change whole gallery_shortcode function. But I wondered if is possible to change only specific output ($captiontag) I wrote:               add_filter( 'captiontag', 'my_captiontag' );          function my_captiontag( $captiontag ) {      $output .= "       <{$captiontag} class='wp-caption-text gallery-caption'><p>       " . wptexturize($attachment->post_excerpt) . "       </p></{$captiontag}>";     }      but it doesn't work :(


determining if the user is logged in

I am new to wordpress, and trying to get my head around the idea of sessions and all. I read in a lot of places that session concept is not used in wordpress. Anyway, I downloaded the my-login-theme plugin. My question is, when a user navigates to some secured area, I want to check if that user is logged in or not. Once I check that, I want to get user details like email, and full name. Is this possible in wordpress? Thanks


post_date vs. post_modified - what's the difference?

Recently I was surprised to find out that `post_date` and `post_modified` fields contain the same values. Isn't a `post_date` supposed to hold the creation date for the post? And shouldn't only `post_modified` change for all future updates? For now they all get changed simultaneously for every update.


Import Issue (ACF Repeater+WP Ultimate Importer)

I'm trying to import a bunch of data from my DB and there's plenty of fields, now i'm using advanced custom fields, repeaters to be specific. I had to make my own CSV file and I did this by exporting data from my DB and creating a structure in hope that the importer would recognize it by using brackets and square brackets. Which I can show an example of here: http://pastebin.com/ZCic7rG2 To explain the pastebin, at the top you can see the names of what each piece of data would represent whenever a bracket like so `{ }` is shown at the top of the file it'd mean it's a repeater(To make it easier for myself when selecting what what is). Under that it shows the actual data in a structure. Now what happens is, it shows the data correctly(at the top) and after those it shows all the other data of the file. I tried to make my own CSV like so and it didn't work. Is there any other way I could do this or is there any CSV file maker out there that supports repeater files? Or do I get the entire idea wrong.


Problem with wp_enqueue_scripts in plugin

I've created the following plugin which requires a js library, however attempts to load the plugin with the line `add_action( 'wp_enqueue_scripts', 'calc_script' );` in place fail with the error `unexpected T_STRING` any help appreciated.               <?php     /**      * Plugin Name: NME Savings Calculator      * Description: A widget that displays the potential savings from installing solar panels.      * Version: 0.1      * Author: NME      * Author URI: http://nme.com.au      */               add_action( 'widgets_init', 'NME_solar_widget' );                    function NME_solar_widget() {         register_widget( 'NME_solar_widget' );     }          class NME_solar_widget extends WP_Widget {              function NME_solar_widget() {             $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the potential savings from installing solar panels.', 'example') );                  $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );                  $this->WP_Widget( 'example-widget', __('Solar Calculator Widget', 'example'), $widget_ops, $control_ops );              }              function widget( $args, $instance ) {             extract( $args );                  //Our variables from the widget settings.             $title = apply_filters('widget_title', $instance['title'] );             $name = $instance['name'];             $daily_kwh = $instance['daily_kwh'];             $contact_text = $instance['contact_text'];             $cost_label = $instance['cost_label'];             $provide_label = $instance['provide_label'];                  echo $before_widget;                  // Display the widget title              if ( $title )                 echo $before_title . $title . $after_title;                       //Display the name                   echo '
';                           printf( '
' . __('%1$s', 'example') . '
', $name );                      printf( '
' . __('%1$s', 'example') . ' <input type="text" id="daily-average" size="8"/>  0 kw
', $daily_kwh );                      printf( '
' . __('%1$s', 'example') . ' <input type="text" id="quarter-average" size="8"/>  0 kw
', $cost_label );                      printf( '
<input type="text" id="system-size" size="26"/> ' . __('%1$s', 'example') . '
'.'$0 per year!!'.'
', $provide_label );                       echo '
';                  if ( $contact_text )             printf( '
' . __('%1$s', 'example') . '
', $contact_text );                      echo $after_widget;         }              //Update the widget               function update( $new_instance, $old_instance ) {             $instance = $old_instance;                  //Strip tags from title and name to remove HTML              $instance['title'] = strip_tags( $new_instance['title'] );             $instance['name'] = strip_tags( $new_instance['name'] );             $instance['daily_kwh'] = strip_tags( $new_instance['daily_kwh'] );             $instance['contact_text'] = strip_tags( $new_instance['contact_text'] );             $instance['cost_label'] = strip_tags( $new_instance['cost_label'] );             $instance['provide_label'] = strip_tags( $new_instance['provide_label'] );                  return $instance;         }          function calc_script()     {         wp_register_script( 'calc', plugins_url( '/solar/calc.js',  __FILE__ ), array( 'jquery' ) );         wp_enqueue_script( 'calc' );     }     add_action( 'wp_enqueue_scripts', 'calc_script' );              function form( $instance ) {                  //Set up some default widget settings.             $defaults = array( 'title' => __('Type text here', 'example'), 'name' => __('Type text here', 'example'), 'show_info' => true );             $instance = wp_parse_args( (array) $instance, $defaults ); ?>
                 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Headline:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('Introduction Text:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'daily_kwh' ); ?>"><?php _e('Daily KWH Text:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'daily_kwh' ); ?>" name="<?php echo $this->get_field_name( 'daily_kwh' ); ?>" value="<?php echo $instance['daily_kwh']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'cost_label' ); ?>"><?php _e('Cost Text:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'cost_label' ); ?>" name="<?php echo $this->get_field_name( 'cost_label' ); ?>" value="<?php echo $instance['cost_label']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'contact_text' ); ?>"><?php _e('Contact Text:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'contact_text' ); ?>" name="<?php echo $this->get_field_name( 'contact_text' ); ?>" value="<?php echo $instance['contact_text']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'provide_label' ); ?>"><?php _e('Provide Text:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'provide_label' ); ?>" name="<?php echo $this->get_field_name( 'provide_label' ); ?>" value="<?php echo $instance['provide_label']; ?>" style="width:100%;" />
                      <?php         }     }          ?>


List post in wp-admin and sort them

this is my first public plugin called Sort posts in taxonomies. With the plugin I intend to list regular posts and custom post_types in the Category(Taxonomy) edit page in wp-admin. Further give the posibility to sort posts using numeric values or ajax. ## This could be the layout of the content: > Genre - **Taxonomy** > >> Comedy - **Category** >> >>>   1. Escape Plan - **Post** >>> >>>   2. Liar, Liar - **Post** >>> >>>   3. Last Vegas - **Post** >>> >>> >> >> Drama - **Category** >> >>>   1. Gravity - **Post** >>> >>>   2. Escape Plan - **Post** >>> >>>   3. Prisoners - **Post** >>> >>> _Notice that the movie Escape Plan is listed different in different taxonomies._ When I edit the Comedy category I want to list all the posts the category Comedy in that edit page. What I have figured out so far is that I have to use the action `{$taxonomy}_edit_form` as the hook. But I don't know how to get the Taxonomy outside the hook without hardcoding the value. **Any ideas?** This is my sort plugin (achd-sort-posts.php):               <?php     /**      * Plugin Name: Sort posts in taxonomies      * Version: 1.0      * Author: Anthony H          global $wp_query;                    // $taxonomy = get_query_var( $wp_query->query_vars['taxonomy'] );     // $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );          // $taxonomy = $wp_query->taxonomy ;     // This is the hardcoded taxonomy         $taxonomy = 'genre';               add_action( "{$taxonomy}_edit_form", 'sort_term_post');               function sort_term_post ($wp_query) {                   $screen = get_current_screen();              $args = array (             'post_type' => "{$screen->post_type}",             'tax_query' => array(                 array(                     'taxonomy'  => "{$screen->taxonomy}",                     'terms'     => "{$wp_query->term_id}"                 )             )         );              $query = new WP_Query( $args );              // The Loop         if ( $query->have_posts() ) {                 echo '
';             while ( $query->have_posts() ) {                 $query->the_post();                 echo '
' . get_the_title() . '
';             }                 echo '
';         } else {             echo "No posts found";         }         /* Restore original Post Data */         wp_reset_postdata();     }               ?>      And here is the custom post_type and taxonomy that i have made (achd- movie.php):               <?php     /**      * Plugin Name: Movie post type      * Version: 1.0      * Author: Anthony H      */                    add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'achd_movie',             array(                 'labels' => array(                     'name' => __( 'Movies' ),                     'singular_name' => __( 'Movies' )                 ),             'public' => true,             'has_archive' => true,             'taxonomies' => array( 'genre' ),             'rewrite' => array('slug' => 'movie'),             )         );          }          add_action( 'init', 'create_my_taxonomies', 0 );          function create_my_taxonomies() {         register_taxonomy(             'genre',             'achd_movie',             array(                 'labels' => array(                     'name' => 'Genres',                     'add_new_item' => 'Add new genre',                     'new_item_name' => "New genre"                 ),                 'show_ui' => true,                 'show_tagcloud' => false,                 'hierarchical' => true             )         );     }          add_filter( 'template_include', 'include_template_function', 1 );          function include_template_function( $template_path ) {         if ( get_post_type() == 'achd_movie' ) {             if ( is_single() ) {                 // checks if the file exists in the theme first,                 // otherwise serve the file from the plugin                 if ( $theme_file = locate_template( array ( 'single-achd_movie.php' ) ) ) {                     $template_path = $theme_file;                 } else {                     $template_path = plugin_dir_path( __FILE__ ) . '/single-achd_movie.php';                 }             }             elseif ( is_archive() ) {                 if ( $theme_file = locate_template( array ( 'archive-achd_movie.php' ) ) ) {                     $template_path = $theme_file;                 } else { $template_path = plugin_dir_path( __FILE__ ) . '/archive-achd_movie.php';                      }             }         }         return $template_path;             flush_rewrite_rules();     }               ?>      ## My problem I can't get the taxonomy to be sent to the action hook. Without hardcoding it. How can I retrieve it? Any ideas? ## My end goal To create a plugin that will list posts in a category edit page and have the ability to sort the posts for that category. Maybe with a small textarea and later with ajax. The sorting is category specific so if the post exists in two categories it can have different sorting in each category. The thought is to add a column perhaps called " **term_post_order** " to the " **wp_term_relationships** " table in wordpress database or use the already existing " **term_order** " but it seems that column already is used for some other functions. Is there any existing function to get data from **wp_term_relationshoips** ?


Query custom post type by date field only working when two posts match the query

Hi I am trying to query a custom post by an advanced custom field that is a date field and this is how it is registered in a plugin that I have created to take care of all non-visual aspects of the site:               fields' => array (     array (         'key' => 'field_528eb92c26db4',         'label' => __('Tip of the day date'),         'name' => 'tip_of_the_day_date',         'type' => 'date_picker',         'date_format' => 'yymmdd',         'display_format' => 'dd/mm/yy',         'first_day' => 1,     ),     ),      Now I have a WP_query in a page that is supposed to display the "tip of the day" and this is supposed to be showing the tips that have this date field as today's date. This query looks like this:               $today = date('Ymd', strtotime("now"));         $args = array(                                       'orderby' => 'post_date',                                                                    'post_type'        => 'bounty_tip',         'post_status'      => 'any',         'posts_per_page' => -1,         'meta_query' => array(             array(                 'key' => 'tip_of_the_day_date',                 'value' => $today,                 'compare' => '=',                 'type' => 'DATE'             )         )          );      Now the issue is that this works but ONLY if there are two posts that have the date. It stops working if there is only one... It is quite unusual and I am pulling my hair out trying to fix this. Does anyone have any ideas why on earth this would happen? I just can't understand how it could work to pick up two (so clearly the meta_query is fine) but not just the one. Thanks in advance I need to finish this to get sign off and this is my last resort! Cheers


New WP_Query loop in admin causes problems

I am working on a project where I have a custom post type 'companies' and on this edit page in the Wordpress admin I have some custom made meta boxes, for saving company information, opening hours, pictures etc etc. Since yesterday I added a meta box for Leads to show the posts in the custom post type "leads" of this companies. To show these posts I use a new WP_Query. The leads posts are displayed correctly, but the meta data from my opening hours and pictures are gone now. Does anyone know what I need to change to this loop to use it in a Wordpress admin. (I also tried `wp_reset_postdata();` at the end op the loop). I register the meta boxes first off course and these are the functions in it.               // Company Leads     function stn_inner_company_leads( $post ){              $args = array(              'post_type'     => 'leads',             'meta_query'    => array(                 array(                     'key'   => 'page_id',                     'value' => $post->ID,                 )             ),         );              $leads = new WP_Query( $args );              if( $leads->have_posts() ) {             $counter = 0;             echo '
';             echo '
';             while ( $leads->have_posts() ) { $leads->the_post();                 $counter++;                      $output  = '
';                 $output .= '# ' . $counter . '	';                 $output .= '' . get_the_title() . '	';                 $output .= '' . get_the_date( 'l, F j, Y g:i a' ) . '	';                 $output .= '
';                 echo $output;             }             echo '
';             echo '
';              } else {             _e( 'This company has no leads.' );         }         wp_reset_query();          }      This is my function for opening hours:               // Opening hours             function stn_inner_opening_hours( $post ) {              global $company;              echo '
';         echo '<fieldset>';              foreach ( $company['opening_hours'] as $key => $value) {                  $value[1] = get_post_meta( $post->ID, $key . '_is_open', true );             $value[2] = get_post_meta( $post->ID, $key . '_open', true );             $value[3] = get_post_meta( $post->ID, $key . '_closed', true );                  $output = '
';                  $output .= '';             $output .= __( $value[0] ) . ':';             $output .= '';                  $output .= '
<select name="company_' . $key . '_is_open' . '">';             $output .= '<option ' . ( $value[1] == 'open' ? 'selected' : '' ) . ' value="open">' . __( 'Open' ) . '</option>';             $output .= '<option ' . ( $value[1] == 'closed' ? 'selected' : '' ) . ' value="closed">' . __( 'Closed' ) . '</option>';             $output .= '</select>
';                  $output .= '
' . __( 'From' ) . ':
';             $output .= '
<select name="company_' . $key . '_open' . '">';             for ( $n = strtotime("00:00"), $e = strtotime("23:30"); $n <= $e; $n += 1800 ) {                 $this_time = date("H:i", $n);                 $output .= '<option ' . ( $value[2] == $this_time ? 'selected' : '' ) . ' value="' . esc_attr( $this_time ) . '" >' . $this_time . '</option>';              }             $output .= '</select>
';                  $output .= '
' . __( 'Till' ) . ':
';             $output .= '
<select name="company_' . $key . '_closed' . '">';             for ( $n = strtotime("00:00"), $e = strtotime("23:30"); $n <= $e; $n += 1800 ) {                 $this_time = date("H:i",$n);                 $output .= '<option ' . ( $value[3] == $this_time ? 'selected' : '' ) . ' value="' . esc_attr( $this_time ) . '" >' . $this_time . '</option>';              }             $output .= '</select>
';                  $output .= '
';                  echo $output;              }              echo '</fieldset>';         echo '
';          }      var_dump($post); gives me the following result:               object(WP_Post)#352 (24) {       ["ID"]=>       string(5) "44625"       ["post_author"]=>       string(1) "1"       ["post_date"]=>       string(19) "2014-03-31 06:54:14"       ["post_date_gmt"]=>       string(19) "2014-03-31 06:54:14"       ["post_content"]=>       string(0) ""       ["post_title"]=>       string(12) "Test salon 2"       ["post_excerpt"]=>       string(0) ""       ["post_status"]=>       string(7) "publish"       ["comment_status"]=>       string(4) "open"       ["ping_status"]=>       string(4) "open"       ["post_password"]=>       string(0) ""       ["post_name"]=>       string(12) "test-salon-2"       ["to_ping"]=>       string(0) ""       ["pinged"]=>       string(0) ""       ["post_modified"]=>       string(19) "2014-03-31 06:56:55"       ["post_modified_gmt"]=>       string(19) "2014-03-31 06:56:55"       ["post_content_filtered"]=>       string(0) ""       ["post_parent"]=>       string(1) "0"       ["guid"]=>       string(59) "http://www.mywebsite.com/?post_type=companies&p=44625"       ["menu_order"]=>       string(1) "0"       ["post_type"]=>       string(9) "companies"       ["post_mime_type"]=>       string(0) ""       ["comment_count"]=>       string(1) "0"       ["filter"]=>       string(4) "edit"     }


get_posts post title permalink not working for last item in array

I have a custom field attatched to a post that contains the following array of post titles...               a:6:{i:0;s:21:"Strawberry Cheesecake";i:1;s:15:"Flapjack";i:2;s:14:"Chocolate Muffin";i:3;s:27:"Apple Turnover";i:4;s:13:"Chocolate Cookie";i:5;s:13:"Shortbread";}      I am then outputing those post titles, searching for the related permalink and echoing them out using....               <?php     $speakerarray = get_post_meta($post->ID, 'cpt_food', true);     $arrlength=count($foodarray);          for($x=0;$x<$arrlength;$x++)     {     $foodname = $foodarray[$x];     $posts = get_posts(array('name' => $foodname, 'post_type' => 'food'));     $post = $posts[0];     $permalink = get_permalink($post->ID);     echo '';     echo $foodname;     echo '';     echo "
";     }     ?>      Everything works fine apart from the last result, I have duplicated the issue with numerous items in the array etc.. and its always the last one that fails. It returns the permalink for the page I am currently on instead. Can anyone see why?


301 redirect from old URL structur to new

I recently updated the permalink structure of a website from `/%postname%/` to `/%category%/%postname%/` this is obviously causing 404 errors. Instead of writing 301 redirects for each post is there any way to do this in a more automated fashion, within WordPress? I essentially want to programmatically 301 redirect the URIs from the old permalink structure to the new one.


Remove Custom Post Type menu for non-administrator users.

I've been researching this all day and haven't come up with much results. I want to restrict who can see my Custom Post Types by User Level (or some other way). So if the person logged in is not an 'administrator' the added Custom Post Types are not visible to them. Here is part of a Custom Post Type that I have:               add_action('init', 'portfolio_register');          function portfolio_register() {              $labels = array(             'name' => _x('Case Studies', 'post type general name'),             'singular_name' => _x('Case Study Item', 'post type singular name'),             'add_new' => _x('Add New', 'portfolio item'),             'add_new_item' => __('Add New Case Study Item'),             'edit_item' => __('Edit Case Study Item'),             'new_item' => __('New Case Study Item'),             'view_item' => __('View Case Study Item'),             'search_items' => __('Search Case Studies'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             /*'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',*/             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail')           );               register_post_type( 'portfolio' , $args );     }      And here are the potential solutions that I found that don't work for the Custom Post Type menu removal:               function remove_menus()     {         global $menu;         global $current_user;         get_currentuserinfo();              if($current_user->user_login != 'admin')         {             $restricted = array(__('Posts'),                                 __('Media'),                                 __('Links'),                                 __('Pages'),                                 __('Comments'),                                 __('Appearance'),                                 __('Plugins'),                                 __('Users'),                                 __('Tools'),                                 __('Settings')             );             end ($menu);             while (prev($menu)){                 $value = explode(' ',$menu[key($menu)][0]);                 if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}             }// end while              }// end if     }     add_action('admin_menu', 'remove_menus');      The above works to remove the default menu items but I couldn't get it to remove a Custom Post Type menu. Plus it is username specific, which is ok if I could add more than one user to it.               global $user_login;     get_currentuserinfo();        if (!current_user_can('update_plugins')) {           .......        }      The above didn't work at all. Thanks.


Quick edit screen customization

**Possible Duplicate:** How to show custom meta box on "Quick Edit" screen? I'm trying to edit the quick edit screen on my custom post type "visitor" so that I can add some options for my end-users. My custom post type doesn't require/need a post date, password to view, publish status, or large taxonomy boxes for custom categories of visitors on it. I've already added a custom meta box for the actual edit page, but **would like to enable quick-edit support of those post meta fields while disabling the current quick-edit options.** I also found a post (linked in my possible duplicate) over on wordpress.org's forums, but not sure exactly what it does.


Critical error in final stage of website launch - URLs are BROKEN!

We developed the wordpress site here: wwww.kirschfamilycomputerservices.com/sam/wheresthefairness ^^ URL does not exist now. When the website was done, we transferred the database & theme over to a new host. The issue is odd and really critical. We have to present the website to the client tonight, and none of our URLs are working properly. the index to the new host is this: http://www.advertisingagency.me/wheresthefairness/ The links just under the header to the right are called in a list in the header PHP file and look like this:
     <?php     if ( is_user_logged_in() ) {         echo 'Welcome Back!';     } else {         echo 'Hello! New to WTF?!';     };     ?>      <?php wp_register( ' '  , ' ' , ' ' ); ?>/     <?php wp_loginout( home_url()  ); ?> |     <a href="<?php bloginfo('template_url'); ?>/new-case">State Your Case|      <a href="<?php bloginfo('template_url'); ?>/cases">View Cases
      The only file outside of the theme directory that I edited while designing the site was the general-template.php file, in which I changed the Site Admin link to display as "Dashboard" and made it point to root/dashboard. So the problem is this.. When you go to the website and hover over a link, it shows the correct path to the file in question, however, when trying to navigate to ANY page directly, we are always given this error: > **Not Found** > > The requested URL /sam/wheresthefairness/index.php was not found on this > server. So what do you guys think the problem could be? Could it be somewhere in the WP files themselves? Or does this sound like a database error? I've honestly never encountered something like this. I've never pointed my browser to a very specific path, and had it tell me that it couldn't load the page, because it tried to go to a different path... **1/19/11-4:36pm Edit to add:** We get this error whenever we try to direct link to a post or a page. So essentially, the only pages we can actually view on the new host is the index page, and wp-admin.


How do I pass the category object to a function when is_archive() is true?

The function below is typically used when inside a loop of categories in order to return each category's description. I'm trying to use it to return the individual category's description when viewing a category landing page (mysite/category/somecategory). How do I pass the equivalent object that represents the category? On header.php               if(is_archive()) {     //get the category description     echo get_cat_desc(get_query_var( 'category' ))     }      In functions.php               function get_cat_desc($category){       $the_description = strip_tags($category->description);       if(strlen($the_description) > 200 )      return  SUBSTR( $the_description,0,STRPOS( $the_description,".",200)+1);     else return  $the_description;     }      Here is the function where I'm successfully passing in the category object to the function above...               function my_category_index(){     $categories=get_categories('exclude=1&exclude_tree=1');     foreach($categories as $category) {echo ce4_get_cat_desc($category);}     }


Categories assigned to custom post type not found

Here's my issue: I have assigned a custom post type to certain categories. When I search for these categories, either through search or entering the url directly. However, if I assign a normal post type to a category, it becomes searchable and can be entered by the url directly. I thought I got everything in my custom post type code, but I must have missed something. Any help would be appreciated:               add_action('init', 'create_trainingplan_post_type');          function create_trainingplan_post_type() {     register_post_type('trainingplan', array(         'labels' => array(             'name' => 'Training Plans',             'singular_name' => 'Training Plan',             'add_new' => 'Add New Training Plan',         'add_new_item' => 'Add New Training Plan',         'edit' => 'Edit Training Plans',             'edit_item' => 'Edit Training Plan',             'new_item' => 'New Training Plan',             'view_item' => 'View Training Plans',             'search_items' => 'Search Training Plans',             'not_found' => 'No Training Plans found',             'not_found_in_trash' => 'No Training Plans found in Trash'         ),         'public' => true,     'exclude_from_search'=> false,     'rewrite' => array('slug' => 'my-custom-training-plan', 'with_front' => true),     'supports' => array(         'title',         'excerpt',         'editor',         'custom-fields',         'revisions',         'thumbnail',         'author',         'page-attributes'              ),         'taxonomies' => array('category', 'post_tag') // this is IMPORTANT     ));     flush_rewrite_rules();     }      Thank you for the help so far, I've added comments from the answer I received so far to make it more clear in my question: @ בניית אתרים I can actually search for the custom post type and find it. It's that the categories that are assigned only to custom post types cannot be searched or found. Basically, I am trying to enable a user to search by category, but categories that are assigned to only a custom post type are not appearing. For that matter, even if I type in the direct url of the category, it takes me to an error page: "Sorry, we can't find the category you're looking for at this URL. Please try selecting a menu item from above or to the side of this message to get where you..." @ בניית אתרים I assigned the categories to the custom post type like you would a normal post. While writing the post, I ticked the categories I wanted included. When in the edit posts dashboard, it does confirm that categories are assigned to the cpt. However, when I go to the category url or search for posts within that category, cpt do not show. Thanks again


Can I programmatically login a user without a password?

I'm manually creating users programmatically, and I want to sign in the newly created user. WP makes it easy to access the hashed password, but not the plaintext version. Is there a way to use wp_signon() without the plaintext password? I found one person who claims to have done this here, but it didn't work for me. THANKS!


How do I add a filter to wp_list_categories() to make links nofollow?

How can I add a rel="nofollow" attribute to my category widget listings? I'm currently filtering the call to wp_list_categories with this code in my functions.php...               function my_wp_list_categories($cat_args){         $cat_args['title_li'] = '';         $cat_args['exclude_tree'] = 1;\         $cat_args['exclude'] = 1;         $cat_args['use_desc_for_title'] = 0;         return $cat_args;         }     add_filter('widget_categories_args', 'my_wp_list_categories', 10, 2);      Update: When I try this...               add_filter('wp_list_categories','wp_rel_nofollow');      My links come out with escape slashes...
       Chinese Tea


New loop vs widget

So, I have a sidebar that I'm going to list all posts in, I could just use a widget. But is it proper to use a new loop instead of a widget, or preferential?


Fatal error with a theme

My question is about a theme named **quality control** which was available at wordpress repository. The plugin developer is not available at this moment and I hope I get resolution for my problem here These are the errors and many others are reporting the same error on the theme's official site > Catchable fatal error: Object of class WP_Error could not be converted to > string in /public_html/wp-content/themes/quality-control/single.php on line > 55 and some times... > Catchable fatal error: Object of class WP_Error could not be converted to > string in \wp-content\themes\quality-control\inc\templates\loop.php on line > 37 Could anybody help me with this? I am ready to give admin access to my site to replicate the error **Update :** The WordPress version I am using is 3.1 and I have tried both the 'Quality control' theme versions 1.5 and 2.0 versions . http://ffav.in is the address of web-site and these are the URLs for some example posts with errors : 1) http:// ffav.in/ticket/test/ 2) http:// ffav.in/category/uncategorized/ Thanks!


How to view plugin ratings?

So I recently submitted my first plugin, and have since got a 1-star rating. Is there a place to review ratings and comments on my plugin?


Different menu navigation per category

Hello all you helpful people :) I am using a self modified version of the 2012 theme and I would like to be able to display a different main navigation menu based on the category I am viewing. Firstly is there a plugin for such a thing as a GUI would be easier for me to get to grips with If not I'm guessing it will be PHP in the header.php file? I already have if statements for custom headers per category so I can add the additional code for switching menus in here. Any help is great :) My existing menu code is:
<?php _e( 'Menu', 'twentytwelve' ); ?>
                 <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?>                 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>                   Main menu is called 'Talkative' Custom menu is called 'Pirtek' I cannot see in the existing code what would be changed unless I have to add additional function calls to wp_nav_menu for example               <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' 'menu' => 'Talkative') ); ?>


Changing site_url domain breaks image links

I am using Responsive theme from CyberChimps. I relocated the Wordpress installation on the same server by changing the Url from settings and renaming folder from FTP. Everything is loading, Wp-Admin, CSS, JS, Pages etc. except for a few images, including the site logo. I tried lot of solutions, clearing bowser cache etc. but it didn't worked out. I debugged it and when I go to customize.php, it shows the same old Url for website logo. Can anyone tell me in customize.php line 138, from where exactly its loading `$section->maybe_render();`? I can even see the logos in media library with updated domain. But apparently customize.php has either cached or for some other reason bound to old domain name.. Any suggestions?


is_category() function

I have category which name is '51m series' (it has id 135). Why the expression is_category(51) is true on this category page? I think it should be false according to Wordpress Codex. Is it a bug? Wordpress 3.5.2 `category.php` code:               <?php get_header(); ?>          <?php     if (is_category(array(36, 63, 64, 65, 67))) {         get_template_part('category', 'papers');             }  elseif (is_category(array(5, 62, 61, 23, 17, 151))) {         get_template_part('category', 'icons');     } elseif (is_category(array(25, 50, 51, 52, 53, 54, 55, 56, 58, 71))) {         echo is_category(51);         get_template_part('category', 'gallery-machine');     } else {         get_template_part('category', 'gallery-frame');     }          ?>          <?php get_footer(); ?>      51m series live You may see 1 (`is_category(51)`) on the of the page.


Add content after get_header

I'd like to add content directly after the `div#main` (end of `header.php`) and before `/div#main` (beginning of `footer.php`). I'm using an own child-template (of twentythirteen), that contains only `style.css` and `functions.php` at the moment. I added the following content to my functions.php               function myAddedStuff() {         echo "Stuff";     }     add_action( 'get_header', 'myAddedStuff' );     add_action( 'get_footer', 'myAddedStuff' );      For the footer it works well, since `myAddedStuff()` is executed, before `get_footer`. But for `get_header` I'd like to execute `myAddedStuff()` **afterwards**. How can I do that. Should I use an alternative hook? How can I easily find hooks? Is the an easy way to add contents to certain HTML commands? (e.g. use `div#main` as a "hook").


Remove CSS & JS files from Wordpress Main Page For Increase Pagespeed?

With the reference of http://stackoverflow.com/questions/12463304/wordpress- load-plugin-css-js-in-functions-php-w-conditional-tags answered by @maiorano84 i am using **cforms** , **FancyBox** , **WP Page Numbers** plugins for **Wordpress**. From **Page Speed** point of view i want to remove CSS and JS of these plugin's from all pages except single post page. I also want to put the JS scripts in the footer. below is the code i have been trying but no luck. Would any body help me please?               if ( !is_single() ) {     add_action( 'wp_print_styles', 'my_deregisters', 100 );     add_action( 'wp_print_scripts', 'my_deregisters', 100 );              function my_deregisters() {             remove_action('wp_head', 'wp_page_numbers_stylesheet');             wp_deregister_style( 'fancybox' );              wp_deregister_script( 'fancybox' );              wp_dequeue_script('fancybox');                   wp_dequeue_style('fancybox');              remove_action('wp_print_scripts', 'mfbfw_load');             remove_action('wp_print_styles', 'mfbfw_css');             remove_action('wp_head', 'mfbfw_init');             remove_action('wp_head', 'cforms_style');                  }          } else {  }


Popup form in pricing table created with shortcodes and contact-form-7

I have a pricing table on the website which is created with short-codes and css ~ [pricing column=4 title="Starter" price="$500" per="one time fee" button_url="/#/" button_text="REQUEST A PROPOSAL"] I am having difficulty with a contact-form-7 popup using a URL to invoke it on this page. How do I add this form to the existing short-code setup using FancyBox in the above short-code configuration?


Total Post Count showing wrongly on admin pages list after modifying the query by using `pre_get_posts` hook

I have used `pre_get_posts` hook and made the changes to $query to exclude page from admin pages list by ID, but the total count of posts showing in the admin pages list, is the posts number including the excluded post also.


Remove meta robots tag from wp_head

I am in need to remove just this line `<meta name=robots content="noindex,follow"/>` from `wp_head` but can't find the right hook to use it with `remove_action()`.               <meta name=robots content="noindex,follow"/>      Basically what I want to achieve is to remove just this line from the header but just for the search page. So in this case I would use something similar to:               if ( is_search() ) { remove_action('wp_head', 'whatever-the-action-name-is'); }


Accessing variable from admin panel?

I've created my own admin page in wp-admin folder using add_theme_page() function. How to pass variables from there to my blog? I mean what's the easiest way without arrays etc. I've tried using "globals" but failed. Thanks a lot.