Is it possible to wrap Geo Location search around WP_Query?

I'll just like to add that I have a current working solution in place and works well but I'm looking for ideas of being able to do it better or cleaner if possible. We have hundreds of properties in a custom post type with metakey/metavalue holding the properties longitude and latitude co-ordinates. We allow a visitor to type in a location and a radius to search for those properties in that area. Kind of like a store locator. Here is how I'm doing it at the moment:               // Work out square radius     if(!empty($_SESSION['s_property_radius'])) {$dist = $_SESSION['s_property_radius'];}else{$dist = 50;}     $orig_lat = $_SESSION['s_property_address_lat'];     $orig_lon = $_SESSION['s_property_address_lng'];     $lon1 = $orig_lon - $dist / abs( cos( deg2rad( $orig_lat ) ) * 69 );     $lon2 = $orig_lon + $dist / abs( cos( deg2rad( $orig_lat ) ) * 69 );     $lat1 = $orig_lat - ( $dist / 69 );     $lat2 = $orig_lat + ( $dist / 69 );          // Compile a map search query to get all property ID's.     $mapsearchquery = "                 SELECT `t`.`ID`                 , 3956 * 2 * ASIN( SQRT( POWER( SIN( ( ".$orig_lat." - CAST(`t`.`property_address_lat` AS DECIMAL(9,6)) ) * pi() / 180 / 2), 2 ) + COS( ".$orig_lat." * pi() / 180) * COS( CAST(`t`.`property_address_lat` AS DECIMAL(9,6)) * pi() / 180 ) * POWER( SIN( ( ".$orig_lon." - CAST(`t`.`property_address_lng` AS DECIMAL(9,6)) ) * pi() / 180 / 2 ), 2 ) ) ) AS `distance`                  FROM (                      SELECT `$wpdb->posts`.`ID`                 , MAX(CASE WHEN `$wpdb->postmeta`.`meta_key` = 'chb_homes_for_sale_address_longitude' THEN `$wpdb->postmeta`.`meta_value` END ) AS `property_address_lng`                 , MAX(CASE WHEN `$wpdb->postmeta`.`meta_key` = 'chb_homes_for_sale_address_latitude' THEN `$wpdb->postmeta`.`meta_value` END ) AS `property_address_lat`                 FROM `$wpdb->posts`                  LEFT JOIN `$wpdb->postmeta` ON ( `$wpdb->posts`.`ID` = `$wpdb->postmeta`.`post_id` )                  WHERE `$wpdb->posts`.`post_status` = 'publish'                  AND `$wpdb->posts`.`post_type` = 'homes-for-sale'                  GROUP BY `$wpdb->posts`.`ID`                  HAVING CAST(`property_address_lng` AS DECIMAL(9,6)) BETWEEN '".$lon1."' AND '".$lon2."' AND CAST(`property_address_lat` AS DECIMAL(9,6)) BETWEEN '".$lat1."' AND '".$lat2."'                      ) AS `t`                 HAVING `distance` < ".$dist."             ";          // Just get the ID's     $mapsearchresults = $wpdb->get_col($mapsearchquery);      This returns an array of all post id's that are within the users search parameters. I then past that array to WP_Query to only show posts that have the above ID's using `post__in`. Also I can do other search criteria on the WP_Query afterwards. In the above query I do a square radius check and I know this could be easily done in WP_Query using `meta_query`. But where I get stuck is running the circle radius check. Is there a way I can wrap this in WP_Query? Basically what I'm after is trying to do this all in one rather than doing two lots of queries.


WordPress Skeleton installation

I'm trying to set up a local WordPress installation using WordPress Skeleton, so that I can eventually use WP Stack. I've created a local folder called vcip.com and the local hosts rules to resolve kdev.vcip.com to that location. I went to the WordPress Skeleton GitHub page and downloaded the zip file of the repo. I unpacked the files into my vcip.com folder. I then installed the Git submodule for the wp folder. I set up a local database and user, and added the details to the local-config- sample.php file, and then changed that file to local-config.php. I also added the salts in wp-config. When I visit kdev.vcip.com I get redirected to http://kdev.vcip.com/wp- admin/install.php (local url) and get the message "This webpage has a redirect loop". Have I missed something in the set up? Are there any more variables to configure? Do I need to remove any files from the wp folder? Thanks in advance for your help.


Custom Single Post By Category

I'm trying to get up to speed with the terminology of the ins and outs of WordPress, so apologies. I'm setting up a full site utilizing WordPress and a custom template, basing it on TwentyTen underpinnings. I'm trying to have as much as possible under the "post" Post Type, and the top level "list" pages just be the category pages. One category is "work" I've been able to customize those by making custom category-work.php and loop- work.php files. But how do I go about making a custom single post by category? It looks like making a single-work.php would look for a custom post type called "work." Is there a way to make a single.php modified clone that is triggered by category / category slug?


How to dynamically filter the results in the Admin Box

I'm using P2P to link two CPT. I already connected the two CPT but the default admin box can't fit my needs. Imagine this scenario: CPT 1 have a custom field of YES or NO choice (0 or 1 in database) and is the FROM for P2P. In the CPT 2 I need a custom box for P2P with a select field (YES, NO or BOTH) that filters the results that the P2P brings to connect. Like if Yes is selected the results should show only posts from CPT 1 that contains the custom field market at YES, and vice-versa, dynamically when user is creating a new post in CPT two. I'm new to PHP and WordPress development and don't know where to start that... http://wordpress.org/plugins/posts-to-posts/


List child pages by slug not ID?

I am looking to use the wp_list_pages function to show children pages of a specific page ID. I was able to do this easily, but now I found an issue with it. I am running a Wordpress network of sites (total of 8). I am trying to set this up where I will only need 2 theme folders because there are 2 main blogs with 3 sub sites that fall under each. So, I am trying to make as many dynamic calls in my theme files as possible to prevent duplicating themes for each site. In my sidebar I am using the following code:               <ul>     <?         wp_list_pages('orderby=name&depth=1&order=DESC&show_count=0&child_of=10&title_li=');     ?>     </ul>      The issue I am running in to is, on each of the sub sites the page ID's have changed but my sitemap for the most part has not. So on my main site child_of=10 displays the proper sub pages in my sidebar, but in my sub-sites the child_of=10 is a different page so I am not getting the proper child pages to display. I had a similar issue with pulling in posts but I was able to do the following:               <?         $category = get_category_by_slug('news');         wp_list_categories('orderby=name&order=DESC&show_count=0&exclude=53&title_li=&child_of='.$category->term_id);     ?>      I am trying to achieve a similar solution for wp_list_pages where I use a page slug to identify the child pages instead of the page ID. Been digging around and trying a few posts I have found on Google / here but no luck. Hoping someone can help me out.


Why does is_front_page and is_home always return true for posts in wordpress?

My front page is just a list of the posts separated by category. I'm working on a plugin that get the id of the post but needs to test if the user is currently on the front page:               if(is_front_page()){          do this thing     }     else {          do this other thing     }      problem is, on the post pages it returns true for is_front_page. I tried is_home but get the same result. I have the home in admin set to "latest posts" (not a static page) and displaying the posts on the main page via loop-home. I'm using is_home in the header and getting the correct response.


How does W3 Total Cache Load Images In Stylesheet via CDN?

W3 Total Cache uses all the PHP / WordPress API trickery at hand to make sure all static content (CSS, JS, Images, etc.) is served from the CDN URL. But how does it make sure that even the images referenced in my CSS/stylesheet file are also served from the CDN URL? I checked my CSS file, the path to the images hasn't changed. It's weird how W3TC does that. Does anyone know?


Shortcode perfomance solution

I have a site that is performance critical. Doing shortcodes I thought about the time the server needs to parse and return the content, instead to allow some HTML (`<div class="redletter">`) to go through the TinyMCE editor. In the meantime, my code for that is:               // [redletter]Content[/redletter]     add_shortcode('redletter', 'redletter_do');     function redletter_do($atts, $content = null)  {         return '<div class="redletter"' . do_shortcode($content) . '
';     }      Performance critical or not, I think that nothing could beat a button to allow a `<div>` pass through directly in the visual editor and show - like it does when you press the [B] button to make `<strong>`. So, i'm between keeping the shortcode, or making a TinyMCE button for `<div class="redletter">` and showing the result in the visual editor.


plugin to upload to youtube via wordpress

before you say it, i know that in most situations it's _easier_ to do this the other way around (i.e. upload via yt site then embed) but i _need_ a plugin to upload/manage yt videos via the wordpress admin interface. ive scanned through the plugin directory but cant see any good options. can anyone suggest anything worthy? hopefully something that uses the youtube api: https://developers.google.com/youtube/ thank you!


wp_enqueue_script does not recognize my js file?

my wp_enqueue_script does not seem to work, i can't understand why : i have a child theme of twenty ten,   i wrote this in my functions.php file (in my theme) :               <?php     function my_scripts_method() {         wp_enqueue_script(             'patScript',             get_stylesheet_directory_uri() . '/js/patScript.js',             array('jquery')         );     }     add_action('wp_enqueue_scripts', 'my_scripts_method');     ?>      then in my header :               <script type="text/javascript" src="<?php get_stylesheet_directory_uri().'/js/patScript.js'; ?>"></script>      and the file is :               $(function () {         alert("hello");     });      But alert does not work. The path is correct, when i echo get_stylesheet... it gives me the right path where my file is located. Would you have any idea? Thanks a lot * * * EDIT : the console in Firefox tells me that :               $(function () {      "is not a function" : does it mean it does not recognize jquery? i added :               wp_enqueue_script("jquery");      above my previous enqueue script, but same thing...


Problem with multisite search

I have a question. I am using multi-site on WP 3.6.1 and I am using ShopperPress theme. I have some code and want to try use multisite search. It's working but listing not correctly. Each search doing separating blog to blog. This is my website. Here is example search: http://newinternetshopping.com/?s=example That code you can download from here: http.//newinternetshopping.com/multisite_search.txt Which code should I use for correct listing? Thanks. Best regards, Veli


How to create a button for importing demo content (.xml file)

I want to create a button (Import Demo Content) in my theme option panel. If user click Import Demo Content button then selected .xml file uploaded automatically and send successful message. I searched in Google but unfortunately I don’t find such type of article or tutorial. Most of the results suggest plugging. But I don’t want to use plugging. Thanks


Remove all links to a specific website

So, my cousin owns a fashion blog and she recently had a fall out with a brand of shoes and she wants to remove all the links on all posts that point to the brand website. So, is there a way I can automatically via SQL commands or maybe a plugin check all posts on the blog and turn links like this:
Awesome Product 1
      Into just text without links:
Awesome Product 1
      The ideia is basically to find all links starting with `http://specific- url.com/` and remove the `<a>`tag. Thank you.


is it possible to run some php code within a wordpress page?

I'd like to access a DB table and render it in some data grid format using php on a dedicated wordpress page, accessible to members of a certain group. Is this at all possible with wordpress or is there another way to do so? using wp 3.5 on linux system + mysql thanks


How do I display the latest Flickr OAuth embedded image on the frontpage?

I have a Flickr category among my blogposts where I just paste in the direct links from Flickr, and let OAuth do it's thing to hotlink/embed the photos in the post. On my frontpage I am trying to grab the latest hotlinked/embedded photo from the latest post in the Flickr category in order to display it there. But with no success. I've tried with the `get_the_image();` plugin, but it seems to only read photos that have been inserted into the post using the wordpress gallery. I manage to get `the_title();`, so I know I'm accessing to the right category and post, but I don't have any chance of displaying the image. Does anyone know how I can achieve this? **Update:** I've achieved this with the following code:               query_posts('category_name=flickr&showposts=1');     if ( have_posts() ) : while ( have_posts() ) : the_post();          $meta = get_post_custom();           $photos = array();     foreach ($meta as $key => $value)         if (false !== strpos($key, 'oembed'))             array_push($photos, $value[0]);                          if(preg_match('/src="(.+\.jpg)"/i', $photos[0], $m)) {             echo '<img src="' . $m[1] . '" />';         }          endwhile;     endif;      Unfortunatly that embeddes the full size image from Flickr. I tried combining it with TimThumb, but with no success. Small steps...


Link to File URL by default

Every time I insert an image into my post, the default link is to the image attachment page. How can I change it so it always links to the File address?


Hide a page title in Wordpress 3.0

I can't find the option to hide the page title. Is there some other plugin required to get this functionality? If you look in this video video you can see the option to set the page title. I don't have this option. I'm not looking for a code solution here, I need something which will allow end users to hide the title.


Semi-Private Comments + page comments -> is it possible?

is it possible to do this:   * User need to register and can only see comments written by himself or by an admin. Admins can see all comments   * create a profile page that user can see all their comments related to all posts thanks


Edit part of a post

In some wikis (e.g., mediawiki), if you want to edit part of a page, you can either click an edit link that lets you edit the entire page -- or, if you just want to edit a single section of the page, you can edit just that one section. This is beneficial because it helps avoid conflicting edits by multiple different editors. Does Wordpress have any way to support this? Perhaps via some plugin? The idea is that I should be able to create a post with multiple sections (separated by headings with style Heading 1, say). Then there should be a way to edit just a single section at a time, so that Alice can edit section 1 and Bob can edit section 2 at the same time, without risk of a conflict due to their simultaneous operations. Is there a way to do it?


How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?

I wrote a plugin with custom widgets for the Dashboard. It retrieves information from an XML file, and display the information into the widget. The XML file will be modified a bit every few minutes or so. Right now my plugin works perfectly if the user refreshes the page, it will also grab the new XML file and display the new one, but I would like that the widget refreshes the information without having to reload the page. I assume JS/JQuery will be needed for this, but I'd just like some advice so I can be in the right direction. Thanks!


Upload media files to Amazon S3

I have a site that is running on AppFog.com, and they don't have persistent file storage for things like images uploaded through the wordpress media uploader. The theme I am making for the site includes the Amazon S3 PHP class for some other functionality - and I have that working. What I would now like to do is hook that into the media uploader so that when images are uploaded to my site they also get uploaded to Amazon S3. So I guess what I want is to know what filters are used when uploading media so that I can hook into them and also upload the images (and the relevant thumbnails) to S3. I tried looking through the source but haven't had any joy so far. I should point out that I don't really want to use a plugin to do this - but I am happy to learn from a plugin if anyone has any pointers. Also - since I am using AppFog I don't have access to the server and so can't install anything beyond PHP apps.


Template for individual post designs

I browsed through the suggested posts, and couldn't find anything that was exactly answering my question. I apologize in advance if I'm reposting something obvious here, but there you have it. I want to make a theme that makes it easy to hand-craft my (single page) posts as if I was living without a CMS at all. I do still want these posts to have the benefits of being archived, perma-linked, getting stats, using the media library and so forth from WP, but I want the authoring flow to be as if I started with a blank folder with a "index.html", a "style.css" and a "scripts.js" file every time. It's been a while since I was working with WP, but here's a sort of a checklist of stuff I want.   * The ability to "toggle" which parts of the loop are visible and which aren't. ("toggle date, toggle post title, toggle footer, toggle footer elements, toggle comments link, etc".)   * The ability to specify in the WP authoring space a CSS file and a JS file specific to that post. I guess entering this into textareas would suffice as well.    * Uploading images for backgrounds and other design-related images to a place that's coupled to the post directly rather than just uploading them to a folder via FTP and using the direct links. I'm not sure I'm communicating very well here, but imagine that my motivation is that when I create a post I want full control over how that post looks (again, in single post view) as if I'd designed it from scratch, but I want to take advantage of the handy mark-up that WP creates and the content management abilities of WP. If you _do_ understand what I'm getting at I'd love some pointers to where to start in form of links to themes that incorporate some or several of these features, advice on how to go about letting each post have a dedicated folder with belonging styles, scripts and images without making a godawful mess and so forth. If you _don't_ understand what I'm talking about I'd really love for you to help me out by telling me where I'm being fuzzy so that I can clarify my ideas a bit. Thanks in advance, Martin


Remove link from Page name in navigation bar

I have a wordpress site and there is a navigation bar with menu and submenu. I want to remove link attribute from menu items that have sub menu. Is it possible? because i couldn't achieve to this by this function : `wp_list_page()`.


Allowing Anyone to Register Subdomains on .COM (Currently on .ORG), for WordPress Multisite?

My current site is example.org. What I want to do is allow anyone to register a WordPress multisite on the exmaple.com version of my site. I'm sure you can do this but just don't know exactly how, I've been looking for hours for this but still no luck. Thanks in advance!


How would I create a shortcode to display a custom post within a page or regular post?

I would like to create a shortcode that will extract information for a custom post, and display it within a Page or regular Post. Specific use case: I have a custom post type "Film" for a film festival website. The films are displayed with their own single-film.php, but occasionally the site owners want to write a post or page that mentions a particular film, and would like to be able to pull snippets of the info that has already been entered (eg, Film name, booking info, etc). This would go in a "box" at the bottom of the post, and I'd like to make it easy for them by providing some sort of shortcode. How would I go about doing this? Any recommended resources/tutorials to get me on the right track? What gotchas should I be aware of (eg, multiple loops in a post)?


Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?

I have this custom loop:               <?php // Display the top ones         $args = array(             'post_type' => 'reply',             'post_parent' => $post->ID,             'r_sortby' => 'highest_rated',             'r_orderby' => 'desc',             'order' => 'DESC'         );     ?>               <?php query_posts( $args ); ?>
          <?php while ( have_posts() ) : the_post(); ?>
<?php _e( 'Top Replies' ); ?>

                 <?php bbp_reply_author_link( array( 'type' => 'avatar' ) ); ?>

                 <?php bbp_reply_author_link( array( 'type' => 'name' ) ); ?>                 <?php bbp_reply_admin_links(); ?>                 <?php printf( __( '%1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?>                 <?php bbp_reply_content(); ?>
                 <?php if(function_exists('the_ratings')) { the_ratings(); } ?>

              <?php $most_voted[] = get_the_ID(); // get the id of the most voted post ?>          <?php endwhile; ?>      I would like to retrieve the number of posts (only in this loop). (The is another loop below). Any suggestions?


How can HTML be allowed in Author Bio?

Is there a way to prevent WP from stripping the HTML from the author bio? I need it to keep my paragraphs. Thanks in advance! :) Edit - Although this question has been answered, I will clarify that I was referring to the Bio textarea when editing individual users.


Backup localhost (wamp) database (phpmyadmin) from harddrive files on windows? For WordPress?

Is it possible to backup files from a old hard drive without having access to phpmyadmin? Could someone point me in the right direction?


highlight parent page on menu when child page is on sidebar (and not on menu)

i'm using twenty-eleven, i have on the menu 4 items : Home, About us, Contact, Clients it's a custom menu. The site currently is on localhost, so no preview is available. However i haven't put the child pages on the menu. (as a dropdown menu) I've put them on side bar. Now, Whenever i'm on eg Home page and select a child page from About us (our team) i want the About us page to be highlighted on the menu. I've looked almost everything, assigning classes, .current_page_parent but nothing works. Any help is much appreciated. :) Thanks


Overrride buddypress theme function

I'm using the buddypress theme buddyboss. the main reason was that this theme is able to manage a picture gallery (which works great). i now want to call that picture-function within the members-loop. one of the buddyboss-admins told me: > "you will need the functions from buddy_boss_pics.php. Specifically you need > to use function buddyboss_pics_screen_picture_grid_content() starting from > line: 285. You will need to edit the file to work with the members-loop > since it currently uses displayed_user_id." this is how the function looks:               function buddyboss_pics_screen_picture_grid_content()     {         global $bp, $wpdb, $bbpics;              $wpdb->show_errors = BUDDY_BOSS_DEBUG;              $img_size = is_active_sidebar( 'Profile' ) ? 'buddyboss_pic_med' : 'buddyboss_pic_wide';              $gallery_class = is_active_sidebar( 'Profile' ) ? 'gallery has-sidebar' : 'gallery';              $user_id = $bp->displayed_user->id;         $activity_table = $wpdb->prefix."bp_activity";         $activity_meta_table = $wpdb->prefix."bp_activity_meta";              $pages_sql = "SELECT COUNT(*) FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid'";              $bbpics->grid_num_pics = $wpdb->get_var($pages_sql);              $bbpics->grid_current_page = isset( $_GET['page'] ) ? (int) $_GET['page'] : 1;              // Prepare a SQL query to retrieve the activity posts          // that have pictures associated with them         $sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid' ORDER BY a.date_recorded DESC";              buddy_boss_log("SQL: $sql");              $pics  = $wpdb->get_results($sql,ARRAY_A);              $bbpics->grid_pagination = new BuddyBoss_Paginated( $pics, $bbpics->grid_pics_per_page, $bbpics->grid_current_page );              buddy_boss_log("RESULT: $pics");              // If we have results let's print out a simple grid         if ( !empty( $pics ) )         {             $bbpics->grid_had_pics = true;             $bbpics->grid_num_pics = count( $pics );      How should I change the function?


how to show custom menu in category and its posts?

I have a category X of posts. The category page and it's individual posts are all part of a custom menu consisting of pages and posts. My submenu, in the sidebar, works fine for showing on the pages, but doesn't show up at all on the category page or any of its posts. How can I get it to show up? edit: I solved this, see below (in the comments) for explanations of my two solutions. solution 1:               <?php if( is_singular('menus')) { ?>
<?php wp_list_pages('title_li=&child_of=8'); ?>
              <?php } ?>      Solution 2:               <?php if( is_singular('venues'))  { ?>                <?php wp_nav_menu(array ("theme_location" => "venue-menu")) ?>            <?php } ?>


Settings options not showing up on Sub Menu page in WordPress plugin

So I have a plugin with two user-customisable settings. (It's not complete but I'm getting the framework in place.) When the two settings are on the "general" settings page they work just fine...               add_action('admin_init', 'mj_admin_init');     function mj_admin_init(){         register_setting('general', 'mj_options', 'mj_validate_input');         add_settings_section('mjid', 'MJ Settings', 'mj_callback', 'general');         add_settings_field('mj_notify_email', 'Email', 'mj_email_input', 'general', 'mjid');         add_settings_field('mj_cm_enabled', 'Enable Messages', 'mj_cm_enabled_input', 'general', 'mjid');     }          add_action('admin_menu', 'mj_admin_menu');     function mj_admin_menu(){         do_settings_sections('mjid');     }          function mj_admin(){         // to-do later     }          function mj_callback(){         echo '
MJ Callback function produced this
';     }          function mj_email_input(){         $options = get_option('mj_options');         $value = $options['mj_email'];         echo '<input id="mj_email" name="mj_options[mj_email]" type="text" value="'.esc_attr($value).'" /> Email address';     }          function mj_cm_enabled_input(){         $options = get_option('mj_options');         $value = $options['cm-enabled'];         echo '<input id="cm-enabled" name="mj_options[cm-enabled]" type="checkbox" value=1 '.checked(1, esc_attr($value), false).' /> Checkbox for enabled messages';     }               function mj_validate_input($input){         $valid = array();         $valid['mj_email'] = sanitize_email( $input['mj_email']);         if($valid['mj_email'] != $input['mj_email']) {             add_settings_error('mj_email_setting', 'mj_texterror', 'Invalid email', 'error');         }         $valid['cm-enabled'] = intval($input['cm-enabled']);         return $valid;     }      But I want to put them on a separate submenu page, called "mj-admin-settings". But, try as I might, they won't show up. All I get is the output of the "mj_callback" function. There are no errors in the error logs, even with debug set to true. To do the above I changed the `mj_admin_init` and `mj_admin_menu` functions to the following:               add_action('admin_init', 'mj_admin_init');     function mj_admin_init(){         register_setting('mj-admin-settings', 'mj_options', 'mj_validate_input');         add_settings_section('mjid', 'MJ Settings', 'mj_callback', 'mj-admin-settings');         add_settings_field('mj_notify_email', 'Email', 'mj_email_input', 'mj-admin-settings', 'mjid');         add_settings_field('mj_cm_enabled', 'Enable Messages', 'mj_cm_enabled_input', 'mj-admin-settings', 'mjid');     }          add_action('admin_menu', 'mj_admin_menu');     function mj_admin_menu(){         add_menu_page('MJ Admin', 'MJ Admin', 'manage_options', 'mj-admin-options', 'mj_admin');         add_submenu_page('mj-admin-options', 'MJ Admin - Settings', 'Settings', 'manage_options', 'mj-admin-settings', 'mj_callback');              do_settings_sections('mjid');     }      Does anyone have any ideas as to how I get the settings to display in the submenu please? I've been all over the codex and am stumped!


Add a select box to all widgets

I would like to add a default select box to all widgets placed in the sidebars of my site. This would allow to choose the color of the associated widget. Do you know how i can make this ? I know how to make a custom widget. Thank you


Can You Build Page Templates Without Extra Files

I'm very familiar creating page templates in WP and for this project I really just have one page template with an option to switch the sidebar from the right side to the left side. The problem is that I would hate to have all of that duplicate code in both templates especially since I'll just be swapping css classes on the two elements. Options:   * 2 separate Page templates   * Custom fields    * Custom taxonomies I'm thinking that having a custom taxonomy might be the best solution. The client would see a small box on the right side of the page titled `Visual Options` and there would be a checkbox for `Sidebar on right`. It is intuitive and it is DRY. Is there something else I didn't consider?


have_comments not true for logged out visitors?

For some strange reason, comments aren't being displayed when a user is _not_ logged in. I've done some extensive experimenting with comments.php without any success. Here's a reference to the example page: http://gycweb.org/by-this-will-all-men-know/ If you are logged in, you would see 3 comments. If you are not logged in, nothing but the form. Also, to add to the mystery, when "editing" the post from within the admin and clicking "show comments", it tries and is not able to load the comments. It appears that the "have_comments" conditional is failing for logged out users. I've also tried getting wp_list_comments to return the list with no success. I've checked for plugin conflicts and nothing obvious yet. Have any of you run into this? Any obvious answers?


Custom taxonomy labels won't display

I created two custom taxonomies (Majors and Seminar Types) related my custom post type CEMB Seminar and the labels on the menu, instead of showing the labels I put in are showing "Post Tags". See a screenshot here (I don't have enough reputation to post pics yet): https://picasaweb.google.com/112518288555484095597/WordPressIssues?authuser=0&authkey=Gv1sRgCNeKmKmS2J_ccQ&feat=directlink Here's the code I used to create the custom taxonomies:               // Register the Majors taxonomy     register_taxonomy( 'cemb_seminar_major', array( 'cemb_seminar' ), $major_args );          // Register the Seminar Types taxonomy     register_taxonomy( 'cemb_seminar_type', array( 'cemb_seminar' ), $types_args );          // Set up the Majors arguments     $major_args = array(          'rewrite' => array(             'slug' => 'major',             'with_front' => 'false'         ),         'labels' => array(             'name' => 'Majors',             'singular_name' => 'Major'         )            );          // Set up the Types arguments     $types_args = array(          'rewrite' => array(             'slug' => 'seminar-type',             'with_front' => 'false'         ),         'labels' => array(             'name' => 'Seminar Types',             'singular_name' => 'Seminar Type'         )     );      I thought maybe since I didn't include all the labels, it wasn't creating the labels correctly, so I later added:               'labels' => array(                 'name' => _x( 'Majors', 'taxonomy general name' ),                 'singular_name' => _x( 'Major', 'taxonomy singular name' ),                 'search_items' => __( 'Search Majors' ),                 'popular_items' => __( 'Popular Majors' ),                 'all_items' => __( 'All Majors' ),                 'edit_item' => __( 'Edit Major' ),                 'update_item' => __( 'Update Major' ),                 'add_new_item' => __( 'Add New Major' ),                 'new_item_name' => __( 'New Major' ),                 'separate_items_with_commas' => __( 'Separate majors with commas' ),                 'add_or_remove_items' => __( 'Add or remove majors' ),                 'choose_from_most_used' => __( 'Choose from the most popular majors' )             )      and               'labels' => array(                 'name' => _x( 'Seminar Types', 'taxonomy general name' ),                 'singular_name' => _x( 'Seminar Type', 'taxonomy singular name' ),                 'search_items' => __( 'Search Seminar Types' ),                 'popular_items' => __( 'Popular Seminar Types' ),                 'all_items' => __( 'All Seminar Types' ),                 'edit_item' => __( 'Edit Seminar Type' ),                 'update_item' => __( 'Update Seminar Type' ),                 'add_new_item' => __( 'Add New Seminar Type' ),                 'new_item_name' => __( 'New Seminar Type' ),                 'separate_items_with_commas' => __( 'Separate seminar types with commas' ),                 'add_or_remove_items' => __( 'Add or remove seminar types' ),                 'choose_from_most_used' => __( 'Choose from the most popular seminar types' )             )      But neither changed helped. I noticed my custom post type also didn't have all the labels customized, so I added the labels to that code and the menu changed to reflect the newly added labels, but the custom taxonomies won't do that. What did I do wrong and how do I fix it?


Load the last post of a category

I would like to load the last post when I go to the selected category. For example   if I go to `http://site.com/category`   it loads `http://site.com/category/35/this-is-the-last-post` Does exist some example to follow about that? I'm doing practice with Wordpress and I don't know how can I get the `last post` of a category.


Create a shortcode in Wordpress, again

There're lots of examples both here and on the internet, I've tried but don't seem to be able to achieve what I need although it does feel like it should be simple enough. Basically, I want to be able to use a shortcode like this:               [download]http://site.com/file.doc[/download]      and I need Wordpress to output this:               download file     preview file      Your help would be greatly appreciated. Thanks so much!


Gallery CSS Problem

Right now I'm using a code in the functions to override the default WordPress gallery CSS. But it seems for some reason that WP only wants to let me put 3 images per line in a gallery, despite my CSS. Anybody know how to fix this? My problem can be found here -> http://themeforward.com/demo2/features/gallery-2/ and my CSS is below.               /*////////////////////////////////////////////////////////////////////      //  Gallery     ////////////////////////////////////////////////////////////////////*/     .gallery {     margin:30px 0 auto!important;     text-align:center;     width:680px;     overflow:hidden;     background:#1a1a1a     }     .gallery-item {     float:left;     text-align:center;          background:#000     }     .gallery img {     display:inline     }     .gallery img:active {     }     .gallery-caption {     display:none;     font-size:.8em;     margin-left:0     }     .gal_img {     margin:20px auto 0!important;     text-align:center     }     .gal_caption p {     font-size:1.3em!important;     font-weight:640;     text-align:center;     font-family:Arial, Helvetica, sans-serif!important     }     .gal_description p {     font-size:1.1em!important;     text-align:center     }      EDIT:               //////////////////////////////////////// Gallery     add_filter('gallery_style',         create_function(             '$css',             'return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css);'             )         );          //////////////////////////////////////// Remove default gallery styling     add_filter( 'use_default_gallery_style', '__return_false' );


Get Products within Current Product Category

~~I'm currently playing around with WOOCOMMERCE V2.0.13 and I'm trying to display each product from the current product category (e.g. Construction Products when on the Construction Page), I've managed to display the single products from within the current category but if the product is also in another category (e.g Construction and Enviroment) then the current category breaks and shows zero products either from Construction or Enviroment. If I could get some advice/help on displaying products from the current category and allow it to work with products that are in multiple categories I'd trully apreciate the help and time. I'm more than happy to recode this entire section to make it work, here is my code below please let me know if I've missed anything. Thank you.~~ Finally found the solution myself, I'd like to thank everyone for helping me.                   <?php if ( have_posts() ) : ?>         <?php woocommerce_product_loop_start(); ?>         <?php woocommerce_product_subcategories(); ?>

                     <?php while ( have_posts() ) : the_post(); ?>
                                <a href="<?php echo get_permalink(); ?>">                                 <?php                                     if ( has_post_thumbnail() ) {                                         $image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );                                         $image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );                                         $image_link = get_permalink( $product_id );                                         $attachment_count   = count( $product->get_gallery_attachment_ids() );                                         echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '%s', $image_link, $image_title, $image ), $post->ID );                                     } else {                                         echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '', woocommerce_placeholder_img_src() ), $post->ID );                                     }                                 ?>

                                     <a href="<?php echo get_permalink(); ?>"><?php the_title();?>                                                                                <?php if ( $price_html = $product->get_price_html()) { ?>                                                 <?php echo $price_html; ?>                                              <?php } ?>

                                     <?php                                         $excerpt = get_the_excerpt();                                         echo string_limit_words($excerpt,15);                                     ?>

                 <?php endwhile;?>

         <?php woocommerce_product_loop_end(); ?>     <?php endif; ?>


How to change custom post type position from backend

I have registerd a post type called **Books** in function.php and this post type will display only for editor role. Now when i am login with my dummy editor i am seeing two post type one is Books and second Profile. I want to change default selected Books post type not profile. What i want: My backed view **My Code:**               function codex_custom_init() {       $labels = array(         'name' => 'Books',         'singular_name' => 'Book',         'add_new' => 'Add New',         'add_new_item' => 'Add New Book',         'edit_item' => 'Edit Book',         'new_item' => 'New Book',         'all_items' => 'All Books',         'view_item' => 'View Book',         'search_items' => 'Search Books',         'not_found' =>  'No books found',         'not_found_in_trash' => 'No books found in Trash',          'parent_item_colon' => '',         'menu_name' => 'Books'       );            $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,          'show_in_menu' => true,          'query_var' => true,         'rewrite' => array( 'slug' => 'book' ),         'capability_type' => 'post',         'has_archive' => true,          'hierarchical' => false,         'menu_position' => null,         'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )       );             register_post_type( 'book', $args );     }     add_action( 'init', 'codex_custom_init' );      Any ideas or suggestions? Thanks.


Filtered content appears in the excerpt

I am modifying the content using the "the_content" filter. But this filtering is seen in the excerpts also. Consider the following code,               function modify_content($content = ''){         return 'HELLO ALL' . $content;     }     add_filter('the_content', 'modify_content');      This works in the main content perfectly. * * * ![Filter content in the main post](http://i.stack.imgur.com/ofDaE.png) * * * ## But, if you see in the excerpt, the "HELLO ALL" text is printed, which is unwanted. ![enter image description here](http://i.stack.imgur.com/hZPSf.png) * * * How to avoid or remove the text in the excerpt ??? which is to be added only to the main content ?? I tried changing the priority but it is no use.. Thank you.


Permalinks don't work, Wordpress adds hashtag and postnumber

After moving a Wordpress website from one server to another, the custom permalinks don't work anymore. For example, a (perma)link that used to be /about/ is now /#/4/about, so a hashtag, post number and then then post name. If I type in the /about/ manually, it doesn't recognize it and I'm redirected to the homepage. When I click on the logo to go to the homepage, a /#/ hashtag is also added after the domainname. I have 'saved' the permalinks Wordpress option to recreate the htaccess file but doesn't make a different. Wordpress 3.5, Theme: Osaka 1.4 Plugins: All in One Favicon, Google Analytics for Wordpress Thanks for any suggestions on how to get the permalinks to work again!


Load a theme based on browser detection

Ok I know browser detection is considered bad practice but I can't find a way around it because I really do need whole different themes for a complex site. So I snatched this function from http://detectmobilebrowsers.com/               $useragent=$_SERVER['HTTP_USER_AGENT'];      if(preg_match('/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|meego.+mobile|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))     header('Location: http://detectmobilebrowser.com/mobile');      not gonna make that fit this box So how I can I use this to load a specific theme that I already have uploaded to my themes folder?


get_post_terms not working as expected

I have a custom post type called "Fruit" and under this I have a hierarchical taxonomy called, "Fruit Categories" When I create a new post under Fruit, I am able to assign it to a "term" - like you would with a normal post category, but under the Fruit Categories taxonomy. I've added three posts to Fruit, with each assigned to a single term respectively; "Apples", "Pears" and "Bananas". All this works fine, but now I want to create an archive page that simply lists the terms in a UL, for that custom post type, like so; mysite.com/fruit   * Apples   * Pears   * Bananas This problem I am facing is that every query I have used only seems to return the first term, Apples. The other two are not showing and I've tried many code snippets, all with the same avail. Some things I've tried;                   $term_list = wp_get_post_terms($post->ID, 'fruit_categories', array("fields" => "all"));  print_r($term_list);      And               $terms = wp_get_post_terms($post->ID,'fruit_categories');     $count = count($terms);          if ( $count > 0 ){         echo "
";         foreach ( $terms as $term ) {             echo '
slug, 'fruit_categories').'">'. $term->name . "
";         }         echo "
";     }      I also tried the tips suggested here, however, this still results in the same issue with just the first term being listed. http://stackoverflow.com/questions/15502811/display-current-post-custom- taxonomy-in-wordpress It's a fresh install with no plugins. Do I need to add a foreach loop to pull in the additional terms? Or is there something I am missing here? I've also been looking at wp_get_object_terms but I don't really understand how to use it. When I do a screen dump, I get the following on mysite/fruit Apples Array ( [0] => stdClass Object ( [term_id] => 43 [name] => Apples[slug] => apples [term_group] => 0 [term_taxonomy_id] => 43 [taxonomy] => fruit_categories [description] => [parent] => 0 [count] => 2 ) ) For what it's worth, here is my Custom Post Type and taxonomy registry code http://pastebin.com/K8kwuzqt Any help much appreciated.


two sites, same code, different presentation

I have created two web sites. One is "production" and the other "dev". Each is a virtual host and both are on a single server running apache. Both sites are loaded with the same code base: WP 3.5.1, a base theme and a child theme. This is not a multi-site setup; just two sites loaded in different directories. The page in question uses a page template. In the page template there is some switching in PHP code to choose what to display. The switching is based on the $current_user->ID. If ID is null or zero display a logon block otherwise look up some data to present. This works fine on the dev site. It does not work on the production site. Something is different. I checked .htaccess, the virtual host declaration in apache, and the settings for WP and the theme. They all appear to be the same. I have run delta checks on the code and the two sets of files are identical. What other config settings might be in play here?


How to have more post in a page than in your home page

I am new to the world of WordPress.   I own a new site and I'd like my home page to display the latest news and articles (which I accomplished to set in _Settings > Reading_ ), but I'd like another page to display all posts (not the whole post but a summary) without the need to press "previous page". e.x.   If I have 8 posts and I set maximum posts to be 4 in the settings menu, my home will have 4 posts. But I'd like the other page to have all 8 posts in summary without the need to press previous page to read other posts.   How can that be done?


Navigation menu displays permalinks

I am creating a theme from scratch and the navigation menu is disturbing me because it is displaying the permalinks after the menu item name. See this picture http://imagebin.org/212406 Link name (#permalink) is the result of `wp_nav_menu()` Setting e.g. `$before/$after` - yields text before/after (#permalink) The (#permalink) part is not displayed in the source. Since it's only Pages I tried wp_list_pages(), but that gives me the same result. Any ideas on how to remove those permalinks? I believe there is some 'default' setting for how links/menu items should be displayed but I don't know where to look. Thanks!


Wordpress & Ajax

I'm creating a plugin and I want to implement drag & drop capabilities that save the order of li's in a list and then displays that list on the front end of the website. I may be a little over my head as I don't know a lot about ajax. Are there any barebones and simple tutorials out there that explain something similar to this?


redirect pages with no content, instead of 404 error, using max_num_posts?

I have a site that has changed its pagination structure, resulting in a huge amount of 404 errors (more posts are being shown per page than previously, so there are lots of pages that were once indexed in search engines that are now 404'ing). What I want to do is create a function that will check whether a page number is greater than the max_num_pages value, and if that's the case interrupt the default wordpress behaviour which is to serve a 404 page, and instead 301 redirect it to either the home page, or better still the initial tag page chosen (we're only interested in tag pages in the overall structure). What I don't know though is how - or more precisely when to use this function. I'm guessing that WordPress already has a function that checks this info, which in turn triggers the 404, so maybe I need to set it up as a filter to an existing pluggable function? The function so far is               redirect_tags(){      if (is_main_query() && !is_singular() && is_paged())      {global $wp_query;     $paged = intval(get_query_var('paged'));     $max_page = $wp_query->max_num_pages;     if($max_page < $paged){     echo 'page is greater than max';}      }}


Get posts of ONE taxonomy term of custom post type

I am going crazy here as I assume it is quite simple, but I just cannot get it to work. I have a custom post type called 'portfolio' and a taxonomy called "locations'. In the taxonomy I have various terms, like 'paris', 'berlin', 'london' etc. How can I get only the posts which are related to one term, e.g. 'paris'? I am trying the following code, yet it gives me the ALL the posts of the taxonomy 'portfolio' and not just of one term:               <?php     $args=array(     'post_type' => 'portfolio',     'locations' => 'paris'     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {     while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
     <?php     endwhile;     }     wp_reset_query();       ?>      Hope someone can help! Thank you!


echo variable containing html and the_permalink();

I'am trying to echo a vriable, but the permalink does not work as clickable button. The permalink just displayed outside the button. Here is my code:               $perma = the_permalink();          $valid = '<button class="btn btn-success btn-wide" href="'.$perma.'">                Gegevens opgeslagen
                 </button>';               $id = get_the_ID();          if($id == '2440'){             if($current_user->google_play_gebruikersnaam != ""){                     echo $valid;                   }


Blog index not going to wordpress folder

I just created a blog.mysite.com domain and installed WordPress. However, when I go to blog.mysite.com it isn't redirecting to WordPress - blog.mysite.com/wordpress. Should I move the contents of the /wordpress directory to my blog root folder or create an .htaccess redirect? This is only going to be a wordpress blog so I assume I can move the files instead of creating a redirect, no? Thank you! ;)


Show or hide a widget from pages

I want to add a check option to the wordpress admin sidebar when I am writing a post or a page to display a specific widget. I tried display-widgets plugin but I want to be able to show a widget directly while writing the post. Or is there is another way to do this it will be OK.


Display my location via a smart phone on wordpress

I am doing a charity bike ride for 100 miles from DC to Delaware I would like to update people as I go (at stops of course) Is there any plug in for wordpress that would allow me to auto map my location via my iphone? thanks


WooCommerce Layered Nav Widget

Has anyone used the "WooCommerce Layered Nav" widget. I wonder if the attributes could be visible on the single product page?


How to get default image sizes attribute

How do I get the height and width of default image sizes? I am not talking about custom image sizes, which can be retrieved from get_intermediate_image_sizes(). I want to get size attribute for 'thumbnail', 'medium', and 'large'. **Update** Base on answer by Mridul Aggarwal, looks like i can do:               function get_image_size ($size) {           return (array(get_option($size. '_size_w'),get_option($size. '_size_h'));      }      Is this the only way?


Can't include Language switch in Nav Menu

I am trying to add to my menu bar some language elements. I'm using the qTranslate plugin and I would like to add the language switch to the menu bar. My them is calling in the _header.php_               <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu'));?>      And then I added to my _functions.php_ the following code, which remains without effect :               function qtrans_generateLanguageListCode($id='') {         global $q_config;         if(is_404()) $url = get_option('home'); else $url = '';         if($id=='') $id = 'qtranslate';         $id .= '-chooser';         foreach(qtrans_getSortedLanguages() as $language) {             $classes = array('lang-'.$language);             if($language == $q_config['language'])                 $classes[] = 'active';             echo '
'.$q_config['language_name'][$language].'
';         }     }          function new_nav_menu_items($items) {         $translinks = qtrans_generateLanguageListCode();         $items = $items . $translinks;         return $items;     }     add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );      Could anyone help me to understand what I am missing ? I have to add that I am using a child theme of Twenty Twelve, but this should be without effect. Thanks !


Select User by Joining Multiple Meta Value Results

( I would ask this in the general stack exchange forum but I think it is more relevant here. I'm intentionally using direct queries to the database here. ) I'm trying to select a group of users that have two distinct meta key and meta value parameters. For example, select all usernames and ID for users with both where a meta_key= "key1" and meta_value="value1" and also for the same user where another meta_key = "keyA" and meta_value = "valueA" In otherwords, I have multiple sets of metadata for a user, I'm looking for a specific set of users that meet criteria in two groups of metadata. There is no relation between the two metadata entries, except that they are both applied to the same user. The challenge that I am having is that I guess I'm trying to left join any metadata entry to the respective user without having to do a double query. Is it possible? Here's what I've tried:               SELECT wp_users.ID, wp_users.display_name     FROM wp_users LEFT JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id AND       wp_usermeta.meta_value= 'value1'     WHERE  wp_usermeta.meta_key = 'keyA' AND wp_usermeta.meta_value = 'valueA'       I've also tried this:               SELECT wp_users.ID, wp_users.display_name     FROM wp_users LEFT JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id        WHERE (wp_usermeta.meta_key = 'key1' AND wp_usermeta.meta_value= 'value1')     AND ( wp_usermeta.meta_key = 'keyA' AND wp_usermeta.meta_value = 'valueA')       Both these return empty sets. I suspect that it is only left joining to one usermeta entry and so when I'm telling it to look for the second set of values in the usermeta entry that has been left joined to the user entry that it returns an empty set. My question is how do I filter through all the user meta info so that I can only return users with results that match both. Thanks for looking! -------- UPDATE -------------- This is the final code that worked for me:               SELECT u.ID, u.display_name     FROM wp_users AS u      LEFT JOIN wp_usermeta AS um1 ON u.ID = um1.user_id      LEFT JOIN wp_usermeta AS um2 ON u.ID = um2.user_id      WHERE  um1.meta_key = 'key1' AND um1.meta_value = 'value1'      AND um2.meta_key = 'keyA' AND um2.meta_value = 'valueA'     LIMIT 0, 60


Order by meta_key with two meta_queries

This should be simple, but I just can't pinned down a good example of the correct syntax to do this. I want to order by the specified meta_key with two meta_queries. The problem is query_posts doesn't seem to like having two meta_queries with a meta_key. If I take out one of the meta_queries the code works, or if I remove the meta_key and change the orderby to title and leave the meta_queries alone it also works. Is there any way to orderby meta_key with two meta_queries?                   $args2 = array(             'meta_key' => '_count-views_all',             //'meta_value' => $id,             'orderby' => 'meta_value_num',             'order' => $sortOrder,             'posts_per_page' => 9,             'paged' => $paged,             'meta_query' => array(                           'relation' => 'OR',                         array(                             'key' => 'contributorid1',                             'value' => $id,                             'compare' => '='                             ),                              array(                             'key' => 'contributorid2',                             'value' => $id,                             'compare' => '='                             )                         )         );         $posts = query_posts($args2);      }


How to delete ALL comments from certain category in Wordpress database?

I'm trying to delete all comments from posts in a certain category in a Wordpress database. The Wordpress database is rather complicated so this must be probably some join of `wp_posts`, `wp_comments` and `wp_term_relationships` as the categories are not stored with neither posts nor comments. How can I do this? I'm struggling to come up with a query.


Fix html inside a for loop

I want to get the right link format for the second link, i tried many time to move the a open tag but no way the result is as the image below.               foreach( $terms as $term ) :               echo '
';              $customposts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=2" );              echo '
';         if( $customposts->have_posts() ): while( $customposts->have_posts() ) : $customposts->the_post();             echo '
';             echo ''.the_title_attribute(); // The problem             endwhile;  endif;             echo '
';         echo '
';         echo '
';     endforeach;      Thanks![enter image description here](http://i.stack.imgur.com/54WpW.png)


Problem with executing a function on saving a post

Here is my basic plugin code. I am just starting from scratch. I will explain the functionality. It is simple, While my plugin is active it will add a new meta box in add new post page just below the tags box. The user can add a value to my text box & i will save that value with post ID to my table. You can understand what is happening after reading my code.               <?php     /*     Plugin Name: Post Extender     Author: Jithesh Kt     Version: 1.0     */          add_action( 'admin_menu', 'extra_meta_form' );     add_action( 'save_post', 'save_extra_meta' );     function extra_meta_form() {         //global $theme_name;         add_meta_box( 'post-meta-boxes', __('Extra Fileds'), 'extra_meta_form_view', 'post', 'side', 'default' );     }          function extra_meta_form_view()     { ?>

Extra Meta filed :  <input type="text" id="custom_input" name="custom_input"/>

     <?php }          function save_extra_meta($post_id)     {         global $wpdb;         $tablename = $wpdb->prefix."extra_post_meta";         $query_result = $wpdb->insert($tablename, array('post_id'=>$post_id,         'filed_name'=>"My Text",         'value'=>$_POST['custom_input']         ));          }     ?>      Now after activating my plugin I clicked on Add New Added a post title, Content & my a value in newly added text box. The result i am expecting in my table is : ![Expected](http://i.stack.imgur.com/uxFQJ.jpg) But actually this what i got in my fresh table :( ![Result](http://i.stack.imgur.com/6bCTR.jpg) How did the data got duplicated ? From where did the other data came ? This is driving me crazy. Running behind this rabbit since last two days. I tried many methods. Same result. Data is always duplicating & unknown data insertion too.


What changes we need to make to a theme so it can be installed as a MU Theme?

I downloaded the free Wootheme Irrestible and **if installed on a stand alone Wordpress** , works **very well**. Now, if we **enable Multiple Sites** on 3.x and set this theme to be the theme of a new site it simply **does not work** out-of-the-box. As WooThemes Support is only for paid customers, and being this a free theme, I can ask for support directly, so I'm kindly ask here for any help. current site with IrrestibleTheme using WP 3.0.1 multi site enable is located at > http://fortiusfitness.com/fblog website settings: ![alt text](http://i.stack.imgur.com/NG7nD.png) As I don't know what might be wrong, here is all settings to this 2nd website:   * settings   * more settings   * and more   * and more   * and more


What is the quickest way to make a widget?

I have some PHP code that I would like to pull out of an existing page of a template, and put into a widget so I can move it around. What is the quickest way to create a widget?


Can Shopp Commercial Plugin be hacked to display radio buttons instead of Dropdowns?

I need to know if the 'Shopp' e-commerce plugin can be modified to display radio buttons instead of drop down menus for the product options. I don't need you to tell me how this can be done (though that would certainly be welcome), just if it is possible. I don't want to invest in Shopp unless it is something that has been done before and there is a thread or article on the Shopp board that explains the hack. EDIT: Seriously, I just need someone w/ access to the Shopp user forums to login and run a quick search for that kind of mod.


Feature Survey - What would you want in a resume theme?

I've been toying with the idea of developing a custom resume/portfolio theme for some time ... but just haven't gotten around to it. Lately, though, I've fallen in love with a few new site designs and feel that it's time we had a truly interactive and dynamic theme to power resumes and portfolios with WordPress. So here it is, your opportunity to participate in a WordPress crowdsourcing project: What features would you _most_ like to see in a resume/portfolio theme for WordPress and why?


query posts only works on the first page

I'm using Jetpack's infinite scroll function on the homepage and I only want to display posts from the category with ID 1. The problem is that my query works correctly only on the first page. On the other pages it displays posts from all categories. Here you have my code               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>     <?php query_posts($query_string.'&cat=1&posts_per_page=12&paged='.$paged);?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <?php get_template_part( 'content' ); ?>     <?php endwhile; endif; ?>      Do you know what's wrong with this? I'm using this code on multiple websites, but I don't have the infinite scroll there.


Shortcodes attributes defaults

I use this construction to implement my own shortcode:               function column_with_icon($atts, $content = null) {         extract(shortcode_atts(array(             'icon' => 'onebit_03'         ), $atts));              return '

' . $content . $icon . '
';     }          add_shortcode('column-icon', 'column_with_icon');      When I try to add a content like this:               [column-icon icon="onebit_13"]
What is Lorem ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
     Learn more
     [/column-icon]      The default value of 'icon' attribute is not overridden and I get it equal 'onebit_03', not 'onebit_13' What can I do about this? **UPDATE** Here is the code I use to retrieve and present the data:               function skible_load_special_offer_section() {         $content = get_option("prc_speciall_offer_text", true);         if (get_option("prc_show_special_offer_section")) {             echo stripslashes(do_shortcode('

' . $content . '

                 '));         }     }


Checking instances of scripts in wp_head

I'm creating a plugin that uses mootools.js. I do not want multiple instances of the script installed on a user's site, if I am able to avoid it. What is the best way to check if mootools.js is already a loaded script?


Custom navigation / menu output (walker?)

I'm trying to implement a responsive jQuery navigation but I need to extend the default output of the WP menu. I believe I need to use a custom walker but honestly, I don't know how to get it to work for me; I just don't know how to get the output I need from it. I need to wrap any pages that have children with a span and remove the link (Friends and Family in the example below). For example:

                         Friends

Alexa

Alexander

Fred

James

Jefferson

Jordan

Kim

Meagan

Melissa

Nicole

Samantha

Scott

                         Family

Adam

Ben

Bruce

Eddie

Jack

John

Martina

Matthew

Olivia

Owen

                         Work colleagues

David

Dennis

Eliza

Larry

Lisa

Michael

Rachelle

Rick


Make Categories and Tags required in admin

Hello i started from Bainternet solution in this post: don't publish custom post type post if a meta data field isn't valid I made a plugin to make categories and tags required. The validation works great and the popup appear correctly, but when the categories and tags are selected, the post is not published...just nothing happen.               /* set category and tag as required fields */          add_action('admin_head','my_publish_admin_hook');          function my_publish_admin_hook(){     if(is_admin())     {         echo"                        <script language=\"javascript\" type=\"text/javascript\">             jQuery(document).ready(function() {                 jQuery('#post').submit(function() {                          var form_data = jQuery('#post').serializeArray();                     form_data = jQuery.param(form_data);                     var data = {                         action: 'my_pre_submit_validation',                         security: '";echo wp_create_nonce( 'pre_publish_validation' ); echo"',                         form_data: form_data                     };                     jQuery.post(ajaxurl, data, function(response) {                         if (response=='true') {                             jQuery('#ajax-loading').hide();                             jQuery('#publish').removeClass('button-primary-disabled');                             return true;                         }else{                             alert('Correggi i seguenti errori: ' + response);                             jQuery('#ajax-loading').hide();                             jQuery('#publish').removeClass('button-primary-disabled');                             return false;                         }                     });                     return false;                 });             });         </script>         ";         }     }          add_action('wp_ajax_my_pre_submit_validation', 'pre_submit_validation');          function pre_submit_validation(){     //simple Security check     check_ajax_referer( 'pre_publish_validation', 'security' );          $error=null;          /* check categories */              $post_data=str_replace("%5D","]",$_POST['form_data']);     $post_data=str_replace("%5B","[",$post_data);          $post_data=substr($post_data,strpos($post_data,"&post_category")+18);        $post_data=substr($post_data,0,strpos($post_data,"&newcategory"));            $categories_array=array();     if(strlen($post_data)>0)     {         $categories_array=explode("&post_category[]=",$post_data);     }        if(count($categories_array)>0)     {         // categories setted     }     else $error="you must select categories";          /* check tag */               $post_data=str_replace("%2C",",",$_POST['form_data']);     $post_data=str_replace("%5D","]", $post_data);     $post_data=str_replace("%5B","[",$post_data);                   $post_data=substr($post_data,strpos($post_data,"tax_input[post_tag]=")+20);        $post_data=substr($post_data,0,strpos($post_data,"&"));          if(strlen($post_data)==0) $error="you must select tags";             //print validation response                if($error==null)        {             echo'true';          die();        }        else        {         echo $error;          die();        }     }


Making a particular kind of search engine with Wordpress?

I would appreciate if I get to know details and how-to make a particular type of search engine with Wordpress,where users can submit/showcase their product and submit their listings of products.It would be a user submitting site.


Using Magic Fields Image-Uploader with Thumbnails

I use Magic Fields a lot to give my clients and users the ability to upload specific content to their websites. Is there a way to call images by their size? At the moment I just put out the images, the persons uploads. But right now I need a solution that gets a specific size from the uploaded picture. I know that Magic Fields uses the default Image-Uploader by wordpress which creates predefined sizes by default. Is there a way to get those sizes while calling the magic field with the uploaded image?


Complex Slider Shortcode Help

I have a PHP-Code for Slider which I found. Now I want to transform it into a Wordpress shortcode. Here's the Code:
                 <div class="big-slider" id="big-slider"<?php echo ($timeout?' data-timeout="'.$timeout.'"':'')?>>

                              <?php                             $i=1;                             $checkerboard=get_option('homepage_slider_checkerboard');                             foreach($slider as $slide) {                                 if($checkerboard == 'true')                                     $flip=!($i%2);                                 else                                     $flip=false;                                      if(@$slide['link'])                                     echo '';                                 else                                     echo '
';                                      $pic='';                                     if(@$slide['video_embed'])                                         $pic.=''.$slide['video_embed'].'';                                     elseif($slide['bgimage'])                                         $pic.='';                                 $pic.='';                                      $text='                                                                                '.$slide['title'].'                                                 '.$slide['description'].'                                                                                ';                                      if($flip)                                     echo $text.$pic;                                 else                                     echo $pic.$text;                                      if(@$slide['link'])                                     echo '';                                 else                                     echo '
';                                      $i++;                             }                         ?>

                   I already started with, first I've created the container which looks like this:               function shortcode_slider($atts, $content = null) {     $str = '';     $str .= '
';     $str .= '
';     $str .= '
';     $str .= '
';     $str .= do_shortcode($content);     $str .= '
';     $str .= '
';     $str .= '
';     $str .= '
';     $str .= '
';     $str .= '';     $str .= '
';     $str .= '

';     $str .= '
';     $str .= '';     $str .= '

';     $str .= '
';          return $str;      }               add_shortcode('slider', 'shortcode_slider');      But now I am hanging with the nested shortcode to create, since I am not experienced PHP or WordPress coder.


How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?

I would like to display a custom 3.0 menu in my sidebar. I want the list to be in order of name, and the list to be sequential down the list of the left column and flow down, then into the right column. ![enter image description here](http://i.stack.imgur.com/Frnz2.png) I currently am using css and floating the li's but the problem is the list goes back and forth from left to right column, rather than down the list sequentially. I am using               <?php wp_nav_menu('menu=canon-camcorders'); ?> in my sidebar.php      Then, #sidebar ul#menu-canon-camcorders li.menu-item {width:89px; float:left; margin-right:18px;} What I would like to do is count how many list items there are, then divide it into two and create two ul's from that. My php abilities are sort of patched together without any formal training, so I am kind of lost. I know some jquery, but don't know how to do this in either way. I read this post: How to count nav menu items? But, I couldn't figure it out for my needs. Any help is greatly appreciated. Thank you, Larry


CPT Parent as a page and CPT Child as a posts

I have one CPT page named as books and one CPT post named as chapters, I am trying to achive this permalink structure here               book1->chapter11     book1->chapter12          book2->chapter21     book2->chapter22      and so on. Here is my code for books cpt               register_post_type(              'books',             $labels             ,                 'public'                =>  true,                 'exclude_from_search'   =>  false,                 'publicly_queryable'    =>  true,                 'show_ui'               =>  true,                 'show_in_nav_menus'     =>  true,                 'show_in_menu'          =>  true,                 'show_in_admin_bar'     =>  true,                 'menu_position'         =>  100,                 'capability_type'       =>  'page',                 'map_meta_cap'          =>  true,                 'hierarchical'          =>  true,                 'supports'              =>  array(                         'title',                         'editor',                         'author',                         'thumbnail',                         'comments',                         'page-attributes',                           ),                 'has_archive'           =>  true,                 'rewrite'               =>  array(                         'slug'          =>  'book',                         'with_front'    =>  true,                         'feeds'         =>  true,                         'pages'         =>  true                 ),                 'query_var'             =>  true,                 'can_export'            =>  true,              )               );      and for chapters cpt               register_post_type(              'chapters',     $labels     ,                 'public'                =>  true,                 'exclude_from_search'   =>  false,                 'publicly_queryable'    =>  true,                 'show_ui'               =>  true,                 'show_in_nav_menus'     =>  true,                 'show_in_menu'          =>  'edit.php?post_type=book',                 'show_in_admin_bar'     =>  true,                 'menu_position'         =>  100,                 'capability_type'       =>  'post',                 'map_meta_cap'          =>  true,                 'hierarchical'          =>  true,                 'supports'              =>  array(                         'title',                         'editor',                         'author',                         'thumbnail',                         'comments',                         'page-attributes',                         'post-formats'                                     ),                 'has_archive'           =>  true,                 'rewrite'               =>  array(                         'slug'          =>  'book/chapter',                         'with_front'    =>  true,                         'feeds'         =>  true,                         'pages'         =>  true                 ),                 'query_var'             =>  true,                 'can_export'            =>  true,                        )               );      these url's are working fine               localhost/library/book/html     localhost/library/chapter/preface      individually, but when I try this url               localhost/library/book/chapter/preface      currently as per my cpt settings, its gives me 404 error, I tried template redirect and rewrite flush also, but nothing works, now my question are   1. is it possible Parent as a page and Children as a posts?   2. if yes what's wrong with this code, am I am missing here?   3. my main concern is here url rewriting, it should be localhost/library/html/preface where html is the name of the book and preface is the chapter. I searched lot here but didn't get the solution it might look similar question to you, but really I need help. thanks. ## Did some changes like changed parent slug to books and child slug to book/chapters and query_var to chapter so working fine for my question 1 and 2 now looking for 3 question url_rewriting. thanks.


Cannot get Child Theme to load latest version of style.css

I'm using a Child theme set up correctly. But I just cannot get changes in the Child theme style.css to be reflected in the site. Tried emptying the browser cache a million times and it doesn't work! I'v created child template files and they overide the parent ones fine. I have noticed in view sourse it puts a version number on the end of the style sheet like this:- style.css?ver=3.9.1 even though I have created no version! In another site I created there is no versioning of the style sheet, so why is it being put in automatically when I don't want it set. How can I force it to use the most up to date version of the Child style.css file and not version it? Here's my site url:- http://www.peterswebservices.co.uk/


How can I create more "create attachment" custom field - any idea?

define('MY_POST_TYPE', 'myslider');       define('MY_POST_SLUG', 'myslider');            function my_register_post_type () {         $args = array (             'label' => 'Gallery',             'supports' => array( 'title', 'excerpt' ),             'register_meta_box_cb' => 'my_meta_box_cb',             'show_ui' => true,             'orderby' => 'meta_value_num',             'query_var' => true,             'order'    => 'ASC',             'public' => true,             'publicly_queryable' => false,             'show_in_menu' => true,              'capability_type' => 'post',             'has_archive' => true,              'hierarchical' => true,             'menu_position' => null,         );         register_post_type( MY_POST_TYPE , $args );       }       add_action( 'init', 'my_register_post_type' );            function my_meta_box_cb () {         add_meta_box( MY_POST_TYPE . '_details' , 'Media Library', 'my_meta_box_details', MY_POST_TYPE, 'normal', 'high' );       }            function my_meta_box_details () {         global $post;         $post_ID = $post->ID; // global used by get_upload_iframe_src         printf( "<iframe frameborder='0' src=' %s ' style='width: 100%%; height: 400px;'> </iframe>", get_upload_iframe_src('media') );       }


Adding search box for admin on custom admin page

I have fetched some rows on my custom admin page (using hook for adding admin menus). Now I want to add a search box on that page to display only those rows with the 'title' column containing searched string in that column. I'm trying with               SELECT * FROM Table WHERE Column LIKE %      to get the data. Please give me some idea. How to do this stuff?


What Is My Fault With This WP_QUERY ? [ Pagination Problem ]

I did a photo gallery with custom post type. The pagination works correct but, if I click to a category, then it must show all photos of the category with pagination, but page 2 not found. You can test it. http://test.onurunwebsitesi.com Click to Tümünü Göster (Show All) button, and click to deneme (try) category button and click Daha Eski Fotoğraflar (Previous Photos), there are 3 photos (I didn't add the photos, just added photo titles), I'm listing photos posts_per_page=2, but page 2 not found. Sorry for my bad English. I need your help. I'm working with it for a long time. Thanks in advance. My codes: archive-fotograf.php               <?php /** * Displays the Pagination in Custom loop * */?>      <?php get_header(); ?>      <?php $aranan= $_GET['s'];       $kategorim = get_query_var('cat');      $catName = strtolower(get_cat_name($kategorim));      $myterm = get_term( $kategorim, 'fgaleri' );       $myslug = $myterm->slug; ?>
      <?php      $temp = $wp_query; //save old query      $wp_query= null; //clear $wp_query      $rakam= 0;      $wp_query = new WP_Query();      //The query      global $query_string;       parse_str( $query_string, $my_query_array );       $paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1;       $wp_query->query('posts_per_page=2&post_type=fotograf&s=' . $aranan . '&paged=' .     $paged . '&taxonomy=fgaleri&fgaleri=' . $myslug );      ?>

Fotoğraf Galerisi       <form action="<?php echo get_bloginfo('wpurl'); ?>" id="searchformfoto" method="get" name="searchform">      <?php $args = array( 'taxonomy' => 'fgaleri', 'show_option_none' => 'Kategori Seç ve Ara', 'hierarchical' => 1 ); wp_dropdown_categories($args); ?>
      <input name="s" id="sfoto" type="text" value=""/>      <input type="hidden" name="post_type" value="fotograf" />      <input id="searchsubmitfoto" type="submit" value="Ara"/>
      </form>

<?php while ($wp_query->have_posts()): $wp_query->the_post(); $rakam++;       //The loop      ?>      <div class="FGaleriItem2" style="<?php if ($rakam % 5 == 0 ) { ?>margin-right: 2px;<?php } ?>">      <?php      $termargs=array('orderby' => 'count', 'order' => 'desc');      $terms = wp_get_post_terms( $post->ID , 'fgaleri', $termargs );      $t = count($terms);      if ($t>0) { ?>
      <?php $c = 0;      foreach($terms as $term) {      $c++;      if ($c==$t)       {       echo 'term_id . '&s=' . $query_vars['s'] . '&post_type=fotograf" title="' . $term->name . '" ' . '>' . $term->name.' ';      }      } ?>
      <?php } ?>
      <?php if (has_post_thumbnail()) { ?>      <a href="<?php the_permalink() ?>">      <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );      $url2 = get_bloginfo('template_directory') . "/timthumb.php?src=" . $url . "&w=100&h=100&zc=1"; ?>      <img src="<?php if(get_option('of_timthumb')=="true") { echo $url2; } else { echo $url; } ?>" alt="" title="" width="100" height="100" />            <?php } ?>

      <a href="<?php the_permalink() ?>"><?php the_title(); ?>

      <?php if (($rakam % 5 == 0 ) && ($rakam > 4)) { ?>

<?php } ?>      <?php endwhile; ?>

      <?php if(function_exists('wp_pagenavi') ) {           wp_pagenavi(); //function call for plugin pagination( wp pagenavi plugin)      }else{ ?>
            <?php next_posts_link('« Daha Eski Fotoğraflar'); ?>      <?php previous_posts_link('Daha Yeni Fotoğraflar »'); ?>
<?php } //endif      $wp_query = null; //Reset the normal query      $wp_query = $temp; //Restore the query      ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>       functions.php               <?php     add_action( 'init', 'register_cpt_fotograf' );      function register_cpt_fotograf() {      $labels = array(      'name' => _x( 'Fotoğraflar', 'fotograf' ),      'singular_name' => _x( 'Fotoğraf', 'fotograf' ),      'add_new' => _x( 'Yeni Ekle', 'fotograf' ),      'add_new_item' => _x( 'Yeni Fotoğraf Ekle', 'fotograf' ),      'edit_item' => _x( 'Fotoğrafı Düzenle', 'fotograf' ),      'new_item' => _x( 'Yeni Fotoğraf', 'fotograf' ),      'view_item' => _x( 'Fotoğrafı Önizle', 'fotograf' ),      'search_items' => _x( 'Fotoğraf Ara', 'fotograf' ),      'not_found' => _x( 'Fotoğraf Bulunamadı', 'fotograf' ),      'not_found_in_trash' => _x( 'Çöpte Fotoğraf Bulunamadı', 'fotograf' ),      'parent_item_colon' => _x( 'Ana Fotoğraf:', 'fotograf' ),      'menu_name' => _x( 'Fotoğraflar', 'fotograf' ),      );      $args = array(      'labels' => $labels,      'hierarchical' => false,      'supports' => array( 'title', 'author', 'thumbnail', 'custom-fields', 'comments' ),     'public' => true,      'show_ui' => true,      'show_in_menu' => true,      'show_in_nav_menus' => false,      'publicly_queryable' => true,      'exclude_from_search' => false,      'has_archive' => true,      'query_var' => true,      'can_export' => true,      'rewrite' => array('slug' => 'fotograflar'),     'capability_type' => 'post'      );      register_post_type( 'fotograf', $args );      }      register_taxonomy("fgaleri", "fotograf", array("hierarchical" => true, "label" => "Fotoğraf Kategorileri", "singular_label" => "Fotoğraf Kategorisi", 'show_ui' => true, 'show_tagcloud' => false, "rewrite" => array('slug'=>'fkat')));          add_filter( 'request', 'my_request_filter' );     function my_request_filter( $query_vars ) {     if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {     $query_vars['s'] = " ";         }     return $query_vars;     }          function limit_posts_per_archive_page() {        if (is_post_type_archive()) { $limit = 2; } else { $limit = get_option('posts_per_page'); }          set_query_var('posts_per_archive_page', $limit);     }     add_filter('pre_get_posts', 'limit_posts_per_archive_page');          ?>


Custom Text in Media Uploader in a Theme Options Page

I want to replace the media uploader thickbox text only if it's used in the theme options page. If it is used in the Post then I don't want to make any changes. I am trying the following code, but this will change media uploader text in the post as well.   How can I make it to change text only in the theme options page?               add_filter("attribute_escape", "myfunction", 10, 2);     function myfunction($safe_text, $text) {         return str_replace("Insert into Post", "Use this image", $text);     }


Wordpress Customizer: custom redirection after closing

Someone knows if is there a way to customize the redirection after a user click "close" in the Wordpress Customizer" live editor? It would be very useful. Thank you very much.


When taxes are country specific they don't show in the cart totals

If the tax you're adding is country specific (EU countries for example) the tax estimate is not shown in the cart totals (although I'm logged in with user specified its EU billing address). But it is shown in the checkout page. I would like to ask if there is any way the tax is shown in the cart page just like it is when it isn't country specific tax. I mean this: when the taxes country code is left blank (meaning it applies to all) this is the message and screen you get ![enter image description here](http://i.stack.imgur.com/Ez2Fq.png) which is pretty awesome and works for me. But when you add a country specific code in my case DE, I don't get it in my cart page although I'm logged in with user with billing address Germany. ![enter image description here](http://i.stack.imgur.com/BuMpw.png) I get the tax in my checkout, but not in the cart which I think might be quite misleading. I hope theres a solution for this ![enter image description here](http://i.stack.imgur.com/7VUAH.png)


Unfortunately removed myself as plugin committer

Unfortunately I removed myself as plugin committer. I was only committer of my plugin. So that, I couldn't find any options to add me back again. What can I do now? Please Help.


WordPress category not found page prints multiple <h1> tags

I use Yoast and a premium theme, everything, including "normal" 404 page prints valid html, but when I click a link like               mysite.com/categories/a_category      and if there are no posts with that category, the resulting html includes both

      and
Not Found
      I need to change Not Found to an `<h2>` tag, but how? I tried changing `wp-content/themes/mytheme/404.php` but it is already h2, and my changes does not apply for **category 404** page. So I guess it loads the content from another file, but from where ?


Grabbing how many posts by month for a dashboard widget

I am trying to develop a dashboard widget that counts posts or post types by month. I am really not sure how to go about doing this. I know how to create a dashboard widget and all that with post counts, post type counts. I even have a custom one that lists the most recent post types i have. But I have yet to create one with just counting how many posts or post types there are in a month and I am just not sure how to do it. Any ideas and help on this would be awesome. Thank you. :) I would like it to be similar to something like this: ![This is how i would like it to look like.](http://i.stack.imgur.com/xgig2.jpg) This is an update with the script below. However I cannot get it to work.               add_action('wp_dashboard_setup', 'dashboard_test');          function dashboard_test() {     global $wp_meta_boxes;          wp_add_dashboard_widget('month_dashboard', 'Reports Submitted for the Year',   'custom_test');     }          function custom_test() {     global $wpdb;     $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE   post_status = 'publish' AND post_type = 'report' ORDER BY post_date DESC");          foreach($years as $year)               $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'report' AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");              foreach($months as $month)                        if ($month < 10)                 {                     $month = '0' . $month;                  }                       $theids = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'report' AND MONTH(post_date)= '".$month."' AND YEAR(post_date) = '".$year."' ORDER BY post_date ASC");                      echo '
';                                  echo '
' . date( 'F', mktime(0, 0, 0, $month) ). ' (' . count($theids) . ')
' ;                          echo '
';          }      I get this error: Call to a member function get_col() on a non-object in /var/www/vhosts/hibsterlite.com/httpdocs/wp- content/themes/hibsterlite/functions.php on line 209 **Ok I no longer get the error above however I only get one month listed atm. Any ideas guys? :)**


using .htaccess only for wordpress security no plugins

Right now I am using bulletproof wordpress security for my websites, but when i am installing W3 Total Cache plugin it gives me some errors related to .htaccess file and bulletproof wordpress security warns me again to proceed with clicking on create .htaccess file again. NOW, my question is.. Is it okay to use ONLY .htaccess file with complete security measures in it. And use NO security plugin with that.? I have already found some strict measures which i can put in .htaccess file and will enable directory protect in cpanel for wp-admin and wp-login.php So, am i going right.?


Strange error from functions.php files (wp_register_script)

I'm trying to migrate a wordpress site, and I'm receiving this error when debugging on the new server: > Notice: wp_register_script was called incorrectly. Scripts and styles should > not be registered or enqueued until the wp_enqueue_scripts, > admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging > in WordPress for more information. (This message was added in version 3.3.) > in /home/binaryop/public_html/wp-includes/functions.php on line 3049 Line 3049 looks like this (the one beginning with trigger_error)               function _doing_it_wrong( $function, $message, $version ) {          do_action( 'doing_it_wrong_run', $function, $message, $version );          // Allow plugin to filter the output error trigger     if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {         if ( function_exists( '__' ) ) {             $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );             $message .= ' ' . __( 'Please see Debugging in WordPress for more information.' );             trigger_error( sprintf( __( '%1$s was called incorrectly. %2$s %3$s' ), $function, $message, $version ) );         } else {             $version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version );             $message .= ' Please see Debugging in WordPress for more information.';             trigger_error( sprintf( '%1$s was called incorrectly. %2$s %3$s', $function, $message, $version ) );         }     }     }      However, I can't see any use of `wp_register_script` in the functions.php, so I'm confused by what's causing this. Any ideas?


Copy site on same server?

I have a wordpress installation running in my root folder, and I want a copy in /en (including theme, posts and pages). I want a bilingual site and found the plugins too complicated for me - so I decided to simply run a duplicate in /en. I've created the /en folder and download all the wp files from my original install - i've also copied the database. Where do I go from now? Do I need to install wordpress again, or can I just move all the files to my new folder, make a new database based on the old one, and change the settings in wp-config? Thanks!


wp_kses ignore allowed and allow everything

Here is an example:               $allowedPart = "";     $unsafePart = "
A title
";     $unsafePart .= "";          $unsafeString = $allowedPart . $unsafePart;          $allowed = array("a"=>array(                         "href"=>array()                ));          $sanitizedString = wp_kses($unsafeString, $allowed);      `$sanitizedString` should be equals to `$allowedPart`, but something goes wrong and `$sanitizedString` remains the same as `$unsafeString`. What's wrong? ========================== Sorry, after saving to the database, I did `location.reload()`, and consequently in the textarea was maintained the original content, but in database the value is **almost** correct. This secondary issue was solved using: `window.location.href = window.location.href;` However there is a problem, **'href' disappears too** , why? For example `<a href='http://alink.com'>Link</a>` becomes `<a>Link</a>` Trying something like: `$allowed = array( 'img'=>array( 'src'=>array(), ));` `<img src='img.png' />` becomes `<img />` It's as if wp_kses() recognize as unallowed all the attributes in sub-array (like href or src), filtering them and their content. ========================== Using double quotes instead of single ones seems to solve. `$allowed = array( 'img'=>array( 'src'=>array(), ));` `<img src="img.png" />`