How do I use add_action from a class method?

For some context, we're building an activation system for new users of an app using WordPress as a framework. We've got a plugin driving most of our interactions, where all of this code resides. When a new user signs up, they are sent an activate link via email, which when clicked, sends them to an activate page. When they save their details, we want to create the user with appropriate meta data, and redirect them to a custom routing template that shoots them off to their personal subsite. We have the username and password of the newly created user available to us, so we can use wp_signon(). We've got a Registration_Model class that is instantiated somewhere else. Our class method to start the sign in process is where I believe we want to call add_action.               public function sign_user_in() {         add_action( 'init', array( $this, 'auto_sign_in') );     }      Our method to process the sign-in is below, but be aware, I've tested out the function to see if the action is even being cued by WordPress by echoing a string, which does nothing.               public function auto_sign_in()     {         // if ( ! is_user_logged_in() ) {                   //determine WordPress user account to impersonate              $creds = array();              $creds['user_login'] = $this->user->email;              $creds['user_password']  = $this->user->password->one;              $creds['remember'] = true;              $user = wp_signon( $creds, false );              if ( is_wp_error( $user ) ) {                  echo $user->get_error_message();              } else {                  wp_redirect('/_router/'); exit;              }          }     }      It really appears that I'm stuck on the action not being run, or something. Can the add_action be run from somewhere other than the class constructor? Any and all advice or help is appreciated. **EDIT** I've adjusted the function to use `$this` instead of `__CLASS__`, although we still get nothing when hooking into 'init'. Just as a test, I've used the absolute last hook that fires, 'shutdown', and I can echo a test string to the browser using it. So I know that there's a whole bunch of operations loading, so I probably need to move the add_action somewhere else so it fires earlier.


How to using custom DB tables

I create a new theme. One of my targets is to enable the admin to add unique text (html code) to unique table which the theme will automatically create (I mean something like `wp_myhtml`). My questions are:   1. How to define that the theme will create a new table only at the first time the admin activate it (if the table exists - don't create again. I know to do it with pure PHP / SQL, but maybe there is an option with WordPress to create custom tables)?   2. How to CURD rows from this table via the panel? and only read via the website itself? are there unique functions to do this? I don't use `options` functions (add_option, update_option, etc) because the html codes can be very long, and one field of LONGTEXT won't handle it. In addition, I don't use the editor (Appearence > Editor) because I need it in the DB.


Saving custom metabox data with a twist

I've got more than a few metaboxes being used with a custom post type and I'm running into an issue where my data is not being saved as expected. Here is the relevant part of the code, and its within a function hooked to `save_post`.               // Loop through our custom metabox post data     foreach ($_POST['product'] as $key => $value) {         // Clear the previous featured product if it needed         if ($key == 'homefeature' && $value == 'on') {             $wpdb->query(                 "                 UPDATE      $wpdb->postmeta                 SET         meta_value = 'off'                 WHERE       meta_key = 'the_prefix_homefeature'                             AND meta_value = 'on'                 "             );         }              // Update meta         update_post_meta($post_ID, 'the_prefix_' . $key, $value);     }      The query seems to work just fine (I've tested it outside of Wordpress) but in the end the product will not be flagged as the `homefeature`. The weirdest thing is that if I put a `die` in after the above loop finishes, it seems to work as expected. It almost seems like Wordpress is caching the query or something. Any help figuring out why this is happening would be great, and let me know if you need more info/code.


wp_get_archives breakes Html5 validation

I have a issue with **wp_get_archives** because it breaks my **Html5** validation.   Inside validator I get this message: **Bad value archives for attribute rel on element link: Not an absolute IRI. The string archives is not a registered keyword or absolute URL.** My archive links looks like this:   http://robertpeic.com/wordpress_template/2013/01/' />   http://robertpeic.com/wordpress_template/2012/12/' />      I am guessing that those errors are happening because spaces inside my links, now if I change my **Doctype** into **Strict** my page validates **fine**.   Can someone please tell me how can I validate my page as **HTML5**? Thank you!!      My wp_get_archives looks like this:`wp_get_archives('type=monthly&format=link');` Validator link


How to make woocommerce product shortcode a dynamic?

I am using woocommerce plugin in my application, is there any way to make the product shortcode([product id="" sku=""]) of it a dynamic one so that I can send the product id through the url, then the corresponding product is displayed on the page. I require this for making the quickview of the product, on clicking product quickview(I used a quickview plugin which uses product description page URL to show in the popup, I am trying to override the url so that I can send product id appended to it). Can you please also suggest is this the better approach of quickview or any other way


Php code error in wordpress if else statements

I have created an if statement inside the "else" of an if/else statement.However the code below the function does not run.When i remove the function the code below the function runs.Could you please help me out. This code causes the problem:                   <?php $googleplay= get_option('director_googleplay');?>         <?php if($googleplay): ?>             <a href="<?php print $googleplay; ?>">                 <img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/>             </>         <?php endif;?>       The php:                 <?php  $category_id = get_cat_ID('Category Name'); ?>       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>            <?php if ( in_category("1") ) { ?>

           <?php } elseif ( in_category("2") ) { ?>

            <?php } else { ?>
       <?php $googleplay= get_option('director_googleplay');?>         <?php if($googleplay): ?><a href="<?php print          $googleplay; ?>"><img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/></><?php endif;;?>
         <?php } ?>        <?php endwhile;else: ?>
Sorry, no posts matched your criteria.
        <?php endif; ?>
        <?php $facebook= get_option('director_facebook');<?php if($facebook): ?><a href="<?php print       $facebook; ?>"><img src="<?=IMAGES?>/Facebook.png" class=" img-responsive pull-left"alt="Image"/></><?php endif; ?>


WP E-Commerce Update Problems "add_option was called with an argument that is deprecated since"

I recently took over an existing website from a new client that had the Kelontong Premium theme and WP E-Commerce installed. Nothing had been updated since 2011 so I took my time and updated all the plugins wordpress version one at a time, when I updated WP E-Commerce I got the dreaded blank screen. I turned on debugging and got the following errors:               Notice: add_option was called with an argument that is deprecated since version 2.3 with no alternative available. in /wp-includes/functions.php on line 3008           Notice: add_option was called with an argument that is deprecated since version 2.3 with no alternative available. in wp-includes/functions.php on line 3008           Notice: Trying to get property of non-object in /wp-content/plugins/wp-e-commerce/wpsc-includes/shipping.helper.php on line 510 Warning: Invalid argument supplied for foreach() in /wp-content/plugins/wp-e-commerce/wpsc-includes/shipping.helper.php on line 510          Fatal error: Call to a member function get_shipping_method() on a non-object in /wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 278           Notice: is_feed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.) in //wp-includes/functions.php on line 3049       I have tried reinstalling the plugin but it did not work. When I disable the plugin I can see the homepage but it does not function correctly. Any help would be gratefully be appreciated. Thanks


Wordpress - Shortcode or Merge tags

I want to use shortcode feature. The only issue is that, I am having multiple parameters. The code I have till now is :                  add_shortcode('lorem', array(&$this, 'lorem_function'), 10, 1);             function lorem_function() {            return 'Lorem ipsum****';        }             do_shortcode('[lorem]');       But in my case I will be having multiple shortcodes. These shortcodes will be generated by the user and it is dynamic. Is there a way I can create a general function? Using these shortcode I want to retreive the values from the database. Is there a way that, say suppose there are 2 shortcodes [lorem] and [Ipsum] then when I am executing the query then the handler should be called only once to handle both the tags at the same time. In case I call the handler separately, then this will affect the performance as database query will be executed every single time a new tag is invoked. I hope the question is clear enough. If not let me know. I will try to reframe it otherwise. Just one more question. I have seen some plugins use shortcode in {shtcode} format. i.e with curly braces. I assume this will also be follwing shortcode api. Do correct me, If I am wrong about it.


List Posts By Custom Taxonomy

Apologies if this is a stupid question, I've had a google and a look on the site but can't find an answer to my question. I'm working on a project and have created a custom post type called 'books'. I've also created a taxonomy called 'genre', which has a term 'fiction. How do you show all posts of taxonomy type 'fiction'... i.e.               http://www.example.com/books/fiction/      I can get /books/the-book-title/ as standard, but how do I get a listing page to work?


Post Filter by Date and time

I'm trying to get wordpress post by filtering date and time, for example get post 01/02/2014 to 07/02/2014. thanks for the help me.


retrieve data form wordpress into app problem with $.ajax access to an object

i'm working on my first app, based on my blog created with wordpress, anyway the problem is that i can't access to to different categories using json api. This my code:               var requestData = {                  dataRock:'category_name=rock&count=2&order=desc',                  dataPop:'category_name=pop&count=2&order=desc',                  dataElectronica:'category_name=electronica&count=2&order=desc'              };                  $.ajax({                 url: 'http://ultravoz.org/api/get_category_posts',                 dataType: 'jsonp',                 //data:'category_name=rock&count=2&order=desc',                 data: requestData,                      success: function(data) {                          //console.log(requestData.dataRock);                          var albumsRock = function()                     {                                $('albumsRock').html(''); // vaciamos previamente el html                              for(var i=0; i < data[requestData.dataRock].posts.length; i++)                         {                             addAlbum(data[requestData.dataRock].posts[i]);                         }                          }      the problem is this **data[requestData.dataRock].posts.length** , show me this error: **TypeError: data[requestData.dataRock] is undefined** i'm new with objects and javascript, can you give me a help? thanks.


Building plugin with changeable custom post type values...advice needed

I'm about to embark on creating a new WP that, at the core, will rely on a custom post type. I'm building this plugin for a client, but plan to make it flexible enough to release in the future. My client has a specific need for the plugin and I ultimately want it to be flexible enough to meet the needs of many users. As such, I plan to create an admin area where a user can enter the various args that would go into the `register_post_type` function. My thoughts in doing so are that the end user will be able to leverage the power of my plugin while also being able to preciously control the custom post type that the plugin generates. I like the idea of easily giving this control over to non-technical users; however, my concern is that I could invite a number of potential issues by doing so. For instance, imagine that a user uses the interface to name the custom post type "whirly-doos", but later thinks that's a dumb name and decides to call it "howdy-doos". This could potentially orphan their previous custom post types. So...my questions are: is this a good way of going about building this plugin? How would you implement the plugin and maintain a nice balance between customization and stability? Thanks in advance!


Check if user is logged in else login page

I like to secure a certain page for admins. How do I check if a user is logged (and is admin)? Of their not logged in, I want to show the login module.


Check to see if there a wordpress user account and create one if not outside of wordpress

Please note that this was posted on wp-hackers mailing list. Hi guys, Just wondering, does anyone know how I can go about checking to see if there a wordpress account and create one if there isn't? Script that I got: https://gist.github.com/Danielx64/7519092 There a marker in the file that has "// Somewhere here I want to put a check to see if there a wp account" What I want to happen there is that a check get done to see if there is a wordpress account and if there not, create one. Does anyone know if it can be done? PS, I don't need to worry about logging into wordpress as that will get taken care of by a different script. Also anyone who can help me out will also get credit in the source code and readme :) Regards, Daniel


Network setup tab is not shown under Tools

Im trying to create a multisite so I did the necessary steps .i.e 1) created a wildcard subdomain 2) backed up of course files wp-config.php and .htaccess 3) edited the config file with adding line "define('WP_ALLOW_MULTISITE', true);" before the line "...Happy blogging.." and now I cannot continue executing the following steps since the Network setup is not appearing under tools. please help. thank you million for your support


Wordpress site is sloooow, but admin is fast....any ideas?

I have a Linode VPS running a single Wordpress blog. It has been running just fine until today. The admin panel is snappy, but the site is very slow. I am still finishing the site, so there shouldn't be any traffic. When I go to mydomain.com it takes 45+ seconds to load, then each click on the link takes about the same amount of time. I didn't update any WP plugins (or WP), but I did add a google analytics plugin a week ago, but seemed fine. I disabled that and no difference either. I tried rebooting nginx, and then rebooted the whole machine... still slow. My "free -m" output is:                user@myserver~ $ free -m              total       used       free     shared    buffers     cached      Mem:     469        147        321          0          3         45      -/+ buffers/cache:   98        370      Swap:    511          0        511      The weird part is nothing has changed in the last few days....Any ideas?


wp-super-cache exclude file from caching

Is there any mean to exclude a `*.php` file to WP Super Cache?   I've in my `single.php` page an `include news.php`, the file `news.php` contains ten links to my last articles. So I want to cache `single.php` but to exclude `news.php` that is included in `single.php`. It is possible? How can I do that?


WP_Query parameter conflict

I am writing a query to retrieve instances of a custom post type I created called "Specialist". In the query I specify a name and more than one taxonomy.   I want to retrieve just those `specialist` which respect **both** parameters.   If I run the two queries separately, the correct specialists are returned but when I integrate the two in one single query, it seems that the `post_name` takes the priority on the taxonomy. For example, if I run the query asking for a `specialist` named `test` with taxonomy `therapist`, I have back the `specialist` called `test` even if it does not have a `therapist` taxonomy. Here is the code:               $args = array(         'post_type'=>'specialist',         'name' => 'test',         'tax_query' => array(             array(                 'taxonomy' => 'type',                 'field' => 'slug',                 'terms' => 'therapist'             )         )     );          $specialists = new WP_Query($args);


Woocommerce Change The Price Of A Product Once Woocommerce Has Retreived It From Database

In a normal case the Woocommerce retrieves the price from the database and displays it. How can one customize Woocommerce so that when the price of the product is retrieved from the database it is then changed at the very initial stage before it is used anywhere else (for checkout, cart etc). **Visualization:-** ![enter image description here](http://i.stack.imgur.com/yxwfS.png) **Constraints:-** The price should not be changed in the database. PHP script should change the price and manage it. **Progress:-** I'm not getting any directions in this problem. I believe that I've to modify `class-wc-product-simple.php` at `line:68`                      if ( $children_by_price ) {                 foreach ( $children_by_price as $child ) {                     $child_price = get_post_meta( $child, '_price', true ); // that's line 68.                     update_post_meta( $this->get_parent(), '_price', $child_price );                 }             }      so that I can modify the price as it is just retrieved from the database.I know that modifying WooCommerce core is not recommended, but that's okay for me for the time being.


Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php

**I wanted to include some javascript and css files on only some of my WordPress pages.** To do this, I registered and enqueued the files in my child theme's functions.php file, and used conditionals to select my target pages. For example, to include a javascript file only in a page called "publications", I used this:               define('child_template_directory', dirname( get_bloginfo('stylesheet_url')) );          function add_my_js() {     if (is_page('publications')) {     wp_register_script('my_js_script',child_template_directory.'/js/my_js_script.js');     wp_enqueue_script('my_js_script');     }     }     add_action('wp_enqueue_scripts', 'add_my_js');      I added a number of these in my child theme's functions.php file, some being javascript files (using `wp_enqueue_script`), and some being css files (using `wp_enqueue_style`). **There may be more than one page where I wanted to place the files** (say, on an "essays" page as well as on "publications"), so I thought maybe I could do something like:               if ( (is_page('publications')) || (is_page('essays')) ) {     //[etc]     }      **But, as well as the possibility of there being many of them, I may now also be in the situation where the target pages may vary from time to time** , so I'm wondering how to cater for this. I thought of keeping the names of the pages (like "publications" and "essays" above) which would have to go into the conditional, in a database table, then, via a query, placing them into an array ('publications','essays'), and then perhaps using something like `in_array()` in place of the `if` conditional - or maybe a `switch()` statement. Basically I'm wondering (1) what's the best way to write the query first, and (2) how to place the array elements into what sort of conditional (or switch, or whatever), inside the functions. Hope this all makes sense.


Wordpress capabilities on pending post status

I have user with contributor user role. In default if you publish article as contributor you can only view it and you can't delete or edit it. But when you submit new post for review, you can do all those things (edit, delete, preview). I want to restrict edit and delete actions for contributor, if post have "Pending Review" status. I already try many user role management plugins, but none of them have such features. So I want to know is there are any other plugin or any other way to do this. Thanks!


Wordpress MU subdomain vhost

Ok so i have my mu setup with subdomains and need a subdomian to point to a different path. My issue is when i add the vhost file it loads before wordpress and loads it path for everything that does not have an assigned path in my vhosts config. But if i load after wordpress domain install then it trys to create a site for the subdomain entered. What i need is this:   sub2.mydomain.com - points to /path/to/sub/directory   *.mydomain.com - points to /path/to/wordpress/install **UPDATE:**   I am using a domain mapping plugin which i think is causing my issue. All sub sites load fine but when i load a mapped domain to a sub site it does not work. I can not add my mapped domain each time to my vhost config since i plan on allowing others to map domains


Admin to user notices - best practices?

I am trying to replicate specific functionality from my vb forums in my wordpress install. Specifically I can create 'user notices' that are displayed on the front end of the website. Basically I can create a post that only displays to non-logged in users, moderators, admins, etc. My plan of attack is to create a custom post-type so that I can easily organize my notices. I am very comfortable working with post-types, and it seems logical. ## questions: 2) When I create a new 'notice post' what would be the best way to 'categorize' it to target a specific group, i.e. - not-logged-in, moderator, subscriber, etc? _I was thinking about using a custom taxonomy so that I would select a term like 'moderator' in order to categorize the posts._ Where I get a bit stuck is how to best call the post on the front-end without resorting to a ton of if/else statements. (there can and will be about 20 conditions on a pretty high traffic site) if tax_term = moderator then display x, else if not_logged_in display y, else... 2) One important condition is to be able to display the notices to users that have not posted a specific post-type 'forum-topic' within the last 30 days. *Can someone provide me with a function that meets this specific condition? finally: If there is a better way to approach this, I am very open to other ideas. I did search the plugin directory for inspiration but really didn't find anything. thanks


Display the last date, regardless of articles

i would like to display a date on my Blog. I have used this Code for displaying the date: `<?php the_time('l, j. F Y'); ?>` But that uses the time of the latest article. How can i display the current date?


Show shortcode only in posts

I created a shortcode to show the short URL from a post. I use canvas, that has an option to show shortcode after content, but I only want to show the shortcode only in posts, not in homepage. How is possible to do that?


Exclude Child Terms From Parent Posts

How can I exclude the child term posts from showing up in the parent term posts output?? Right now it's duplicating in both parent and child term outputs.                //Function to display posts grouped by taxonomies         function display_posts_per_taxonomies($parent_term, $post_type = 'beat_posts', $taxonomy = 'beats'){         $parent_posts = get_posts(array(         'tax_query' => array( array(         'taxonomy' => $taxonomy,         'field' => 'slug',         'terms' => $parent_term             )),             'post_type' => $post_type         ));         echo '
';         foreach($parent_posts as $post){             echo "
{$post->post_title}
";          }         $children_terms = get_terms($taxonomy, array(             'parent' => get_term_by('slug', $parent_term, $taxonomy)->term_id         ));          foreach($children_terms as $term){             echo '
';             display_posts_per_taxonomies($term->slug, $post_type, $taxonomy);             echo '
';         }         echo '
';        }      Below is what I'm trying to get rid of.

adsf

ergerg
 <---get rid of this one (duplicate)
asdfasdfsdf
 <---get rid of this one (duplicate)
rthhdhdfhdhdfhdfg

ergerg

asdfasdfsdf


What is the current page's Taxonomy?

I need to be able to switch between the current page taxonomy so I can load in the appropriate menu:               $current_tax = 'need to get this from somewhere';     switch ($current_tax) {         case 'tax1':             // load menu1         break;         case 'tax3':             // load menu2         default:         break;     }      I'm not sure which method is best to get the current page's taxonomy.


WP calendar summary attribute validation error

When the calendar widget is activated in the sidebar, it generates the following validation error (W3C markup validation): > The summary attribute is obsolete. Consider describing the structure of the > table in a caption element or in a figure element containing the table; or, > simplify the structure of the table so that no description is needed.               …alendar

      How can I rectify this without messing with any core file? Working with WP3.1.4, twentyten theme. Thanks.


Why does hitting enter in Visual Editor add <p> instead of <br>?

Why does hitting the enter key in Visual Editor add `<p>` instead of `<br>`? What I want sometimes is a new line that starts immediately after the previous line. Unfortunately, the visual editor automatically wraps my new line in a `<p>` tag when all I really want is a `<br>` tag so that there is no space between the two lines. How can I solve this without specifically changing my code in the HTML tab?


Email admin when post pending?

I have this little bit of code that sends me an email whenever a new posts is published by an author, but I want to be alerted to posts in 'pending' status by contributors too.               add_action('publish_post', 'send_admin_email');     function send_admin_email($post_id){         $to = 'myemail@email.com';         $subject = 'New Post on The Articist';         $message = "new post published at: ".get_permalink($post_id);         wp_mail($to, $subject, $message );     }         Can I have emails sent to me so I'm informed when posts are pending? Code from userabuser's first solution, this doesn't seem to actually send emails(yes, I have changed it to my actual email address in the functions.php).               add_action( 'transition_post_status', 'pending_post_status', 10, 3 );          function pending_post_status( $new_status, $old_status, $post ) {              if ( $new_status === "pending" ) {             function send_pending_email($post_id){                 $to = 'myemailaddresshere@mysite.com';                 $subject = 'New Pending Post';                 $message = "new post Pending";                      wp_mail($to, $subject, $message );                }              }          }


Using jQuery in widget development

I'm working on a widget that do some magic with jQuery (slide,fades elements). The problem is that the jQuery script attached to widget is not called when I delete and then replace the widget in the sidebar . Even If I have in the form function something like this :               public function form( $instance ) {              wp_register_script('script', get_template_directory_uri() . '/script.js', array('jquery'), null, true);         wp_enqueue_script('script');     }      The script is present in the page (If I `view source` it is there) but the document.ready function is not triggered so all the onclick action are disabled. Refreshing the page resolve the problem but it's there a way to resolve this somehow ? I need something like `document.on("widget-attached-to-sidebar", function(){});` **EDIT:** Steps to reproduce this problem :   * `refresh the page`   * `my jQuery script works`   * `delete the widget`   * `add it again`   * `my jQuery script is not working anymore (need to refresh the page again)` The script.js is still there in the page (`view source`) through all those steps .


Why can't my admin account manage attachments on a custom post type with a unique capability type?

I've created a custom post type called 'directory' and assigned it the capability type of 'listing'. It has a unique capability type because I want to restrict Contributors to only be able to create/edit/publish this post type, which I am restricting via capabilities. There are the capabilities that were created by the MapCap plugin:   * Delete listings    * Delete published listing posts   * Edit listings    * Edit private listing posts   * Edit published listing posts   * Publish listings   * Read private listings For the Contributor, everything is working properly, and he/she can create, and only edit his/her own posts, and can upload attachments. The Admin account has all the same capabilities, but isn't fully working. I can create a post, and edit any of the others. But it does not give me full rights to the attachments. In the media library, any files I upload with this custom post type can't be deleted when I am logged in as the admin. (I am still able to Trash the attachments by other authors, just not my own uploaded as admin.) The closest thing I've found is this message on WordPress Trac that describes how attachments can't be edited without the edit_post/delete_post capability. I assume this is simply a matter of me not having proper capabilities assigned to the post type, but I've not had any luck finding the right combination.


How to show page title in blog post of wordpress site

I want to show the page title in single post page of wordpress theme. I tried to use `<?php echo get_the_title() ?>` but it returns the post title, not the page title. basically I want to show my page title, in this case "Blog" below my header area in single.php file. how do I make it?


get the image of the post

Im running 'the loop' and I want to get the image of the post (in original size - not thumbnail), how do I do it? thank you.


What is a good way to test that plugin upgrades have completed properly?

I'm working to automate plugin upgrades across all my WordPress installs. Part of that process is making sure the plugins upgraded correctly, didn't introduce errors and don't cause new conflicts with other plugins. Is there a way to check that plugins have upgraded correctly afterwards?


Adding admin menus to wordpress

I am trying to add a menu box to `Pages > Pages` or `Pages > Add New`, basically whenever they access a page, be it to edit an existing page or add a new one, I would like to add a menu box under the `Page Attributes` box on the right, or anywhere on those pages that I can add a input form into to work in conjunction with the plugin I am trying to build. I am very very new to wordpress plugin development, so please forgive my ignorance on the subject, any learning materials or good resources on the subject would also be greatly appreciated! Thanx in advance!


How to save post change url youtube link?

In functions.php i using this to change width url from youtube:               add_action('save_post', 'set_url_youtube');     function set_url_youtube() {         $post = get_post($post_id);          $content = $post->post_content;         preg_match_all('#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z]+)&?.*?)#i', $content, $urls, PREG_SET_ORDER);         if(is_array($urls)) {            foreach ($urls as $url)            $videos_url[] = $url[0];         }              if (is_array($videos_url)) {             $videos_url = array_unique($videos_url);             rsort($videos_url);         }                 if($videos_url) {             foreach ($videos_url as $video_url) {                 $content = str_replace($video_url, $video_url.'&w=550', $content);             }             remove_action( 'save_post', 'set_url_youtube' );             wp_update_post( array('ID' => $post_id, 'post_content' => $content) );             add_action( 'save_post', 'set_url_youtube' );         }     }     ?>      But when save post is, url `http://www.youtube.com/watch?v=KTRPVo0d90w` not change to `http://www.youtube.com/watch?v=KTRPVo0d90w&w=550` How to fix it ?


customize wordpress database error page

**UPDATE** Initially I suspected this was related to the Wordpress framework I'm using (Genesis) or to my child theme functionality, but turns out that's not the case as I was able to get this to work in a test environment running on the same framework and child theme. Possibly this is related to the caching plugin I'm using, W3 Total Cache. If this plugin is not active, then the custom db-error.php file is picked up. To rephrase my question, has anyone run into this issue with caching plugins being active? **ORIGINAL QUESTION** Has anyone successfully been able to replace the default Wordpress database error page with a custom one? I tried this (add db-error.php under wp-content), but I can't get it to work for some reason: http://css-tricks.com/snippets/wordpress/custom-database- error-page/


Get post_type by term_id

Is it possible to find out which post_type a term_id belongs to? I have this bit of code to try and collect all possible categories into an array, but I would like to add the post type each category belongs to into the array.               $post_catgegories_objects = get_categories(         array(             'type'       => 'post',             'orderby'    => 'name',             'hide_empty' => '0',         )     );          foreach ( $post_catgegories_objects as $cat ) {         $post_catgegories[] = array(             $cat->term_id,             $cat->name,             $cat->slug,         );     }          // var_dump($post_type);     // exit;          $taxonomies = get_taxonomies(         array(             'public'   => true,             '_builtin' => false,         )     );          foreach ( $taxonomies as $key => $taxonomy ) {         if ( stristr( $taxonomy, 'cat' ) ) {             $tax_terms = get_terms( $taxonomy );                  // print_r($tax_terms);             // exit;                  foreach ( $tax_terms as $term ) {                 $cpt_categegories[] = array(                     $term->term_id,                     $term->name,                     $term->slug,                 );             }         }     }          $all_categories = array_merge( $post_catgegories, $cpt_categegories );          print_r( $all_categories );     exit;


Function to limit the number of posts in taxonomy.php

How can I change the post limit for taxonomy.php from that which is defined in the settings page? Currently I have 10 posts displaying per page, which is fine for the blog part of my site, but I want to show all posts when the user is on taxonomy.php, is there a function that can achieve this?


How do i hide the <h2> if the <h1> appears

I'm working on a WordPress site that automatically displays an `h2` on the page as what the page/post is titled. I want to manually create `h1` for some pages and have the `h2` to be hidden if the `h1` appears. Is there a way to do that?


Post 2 Post: Getting connected 'person' from post author

I am using the amazing P2P plugin (many thanks Scribu!) and I am having an issue that is probably right in front of my face but I just can't see. I have a 'People' as CPT and I have connected that to 'Users' with a 'Person_to_User' connection I created. On single posts I want to get the connected 'person' in my 'People' CPT from that post author. It seems like that should be fairly simple to do but my brain is hurting from trying to get this and I can't spend much more time on this.


How to remove some options in visual editor?

I want remove some options in visual editor. How to remove them? For example i want to remove the following.   1. Align left option   2. Align center option   3. Align right option   4. More tag option   5. Add media   6. Toggle fullscreen   7. Toggle spellchecker   8. Show/hide kitchen sink   9. strikethrough Please help me to remove them from my wordpress visual editor. Thanks


Contact form with database integration issue

This is more a question about the idea I am going to share and ask for advice for. I would like to have a contact form on my site, where people complete their data and it gets stored inside a database. I want to have the option that they include a file (any file up to 5mb - pdf, doc, exe, etc..). This needs to be stored in the database or somewhere else as well. Then I want to provide people the access to this database with info and files, and grant the access with a user/password or by IP. Do you know what are my options? Did you have any experience with a plugin that does that? I saw one plugin that stores the data in a db, but not sure how to combine all three points I mentioned here. Advice will be appreciated. Many thanks.


query_posts with sorting on a custom datestamp

I have a custom meta field that I want to use to sort with `query_posts` but its not ordering my posts properly since it is a datestamp (i.e. 04/21/2014) and its treating it like a normal text string. I thought about converting the field using `strtotime` but that doesn't work.               $args = array(       'meta_key'      => strtotime('pexpires'),       'orderby'       => 'meta_value',       'order'         => 'desc',       'post_type'     => 'post',       'showposts'     => '60',     );     $query = query_posts($args);


Make email not required comments.php

I need to edit my comments.php to make emails NOT required. I've attached my code below, I understand that I need to get rid of $req and $aria_req from my email field, but as the site is live I don't want to try and make any changes without doing it properly. Thank you!               $author_name = get_comment_author();          $args = array('title_reply' => __( 'Post a new comment' ),                   'title_reply_to' => __( 'Post a new comment' ),                   'label_submit' => __( 'Submit Comment' ),                   'comment_field' => '

<textarea id="comment" name="comment" placeholder="Enter text right here!" cols="45" rows="8" aria-required="true"></textarea>

',                        'fields' => apply_filters(                              'comment_form_default_fields', array(                                      'author' => '

' . __( 'Name', 'domainreference' ) . ' ' . ( $req ? '' : '' ) . '<input id="author" name="author" type="text" value="" size="30" ' . $aria_req . '/>
',                                      'email' => '
' . __( 'Email', 'domainreference' ) . ' ' . ( $req ? '' : '' ) . '<input id="email" name="email" type="text" value="" size="30" ' . $aria_req . '/>

')),                        'logged_in_as' => '
' . sprintf( __( 'Posting as %2$s (Logout)' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '
',                         'cancel_reply_link' => __( 'Cancel' )                        );          $args_log = array('title_reply' => __( 'Post a new comment' ),                   'title_reply_to' => __( 'Post a new comment' ),                   'label_submit' => __( 'Submit Comment' ),                   'comment_field' => '

<textarea id="comment" name="comment" placeholder="Enter text right here!" cols="45" rows="8" aria-required="true"></textarea>

',                        'fields' => apply_filters(                   'comment_form_default_fields', array(                        'author' => '

' . __( 'Name', 'domainreference' ) . ' ' . ( $req ? '' : '' ) . '<input id="author" name="author" type="text" value="" size="30" />
',                        'email' => '
' . __( 'Email', 'domainreference' ) . ' ' . ( $req ? '' : '' ) . '<input id="email" name="email" type="text" value="" size="30" />

')),                        'logged_in_as' => '
' . sprintf( __( 'Posting as %2$s (Logout)' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '
',                        'cancel_reply_link' => '
'.__( 'Cancel' ).'
'                        );


Using twitter bootstrap in a theme

Recently I made a simple web template using basic HTML and twitter bootstrap along with my own custom CSS. I want to convert that into a WordPress theme. I know how to create WP theme from basic template . But how can I integrate twitter bootstrap with it? If I put `bootstrap.css`, `bootstrap-responsive.css`, `custom.css` (my custom CSS file) into the CSS folder of WordPress theme, and `bootstrap.min.js` into my js folder of wp theme , will it work?


Widget Screen Locked

Within the Wordpress dashboard, the widget screen is locked and it won't allow me to drag new widgets within the sidebars - or remove any that's there. I've seen suggestions to toggle the 'screen options' from that page, but there that button is locked as well within that page in the dashboard. I've tried deactivated plugins and installing a 'cache clear' and still nothing. **Anyone have any suggestions as to why this is happening?**


Can't view network plugins.php or upgrade-core.php on multisite

I have a network with 5 or 6 sites. In the network admin panel I can see all pages except the /wp-admin/network/plugins.php page and the /wp- admin/network/upgrade-core.php page. Both of those files exist when viewing the folder structure, but for some reason they won't load. Any help is appreciated.


How to remove 'create new post' entry for a custom post type?

I have a custom post type that is created using a form on the site. I want to disable new post creation from wordpress admin. Is there a way to do that ?


unable to wp_enqueue_script('suggest');

i'm not able to enqueue the built in autosuggest script in my wordpress theme.               wp_enqueue_script('suggest');      my current workaround for that problem is to deregister, register manually an then enqueue it – like so:               wp_deregister_script('suggest');     wp_register_script('suggest', '/wp-includes/js/jquery/suggest.js');     wp_enqueue_script('suggest');      i can't figure out how to solve this problem, because i get no error at all (WP_DEBUG defined TRUE) thanks for your thoughts, hans //update sorry for being a bit cloudy with the description of my problem: i am working on a wiki-like thing based on wordpress. there is one page where users can upload new images and tag them (this is where i need the suggest.js). the templatefile for this page looks like:               <?php     //enqueue scripts + styles     wp_enqueue_script('uploadify', get_bloginfo('template_directory') . '/js/uploadify/jquery.uploadify.v2.1.0.js', array('jquery'), null, null);     wp_enqueue_script('swfobject', get_bloginfo('template_directory') . '/js/uploadify/swfobject.js', array('jquery'), null, null);     wp_enqueue_script('jcrop');     wp_enqueue_style('jcrop');     wp_deregister_script('suggest'); //workaround     wp_register_script('suggest', '/wp-includes/js/jquery/suggest.js'); //workaround     wp_enqueue_script('suggest'); //workaround          ...          get_header();          page content that uses scripts & styles          get_footer();     ?>      at the very beginning of the file i'm enqueueing the additional styles/scripts i need for that single page. (other "basic" scripts + styles get enqueued in my functions.php) enqueueing jcrop for example works without any problems…


Exclude current page from list of pages

I'm using [catlist categorypage=yes post_type=page] in the sidebar to display a list of pages with the same category as the current page. Wonderful, but it returns a link to the current page. Is there a simple way to exclude the current page from the results?


How can I include custom post types on a tag page?

I'm using custom post types, but they don't appear on tag pages along with regular posts and i'd like to include both standard and custom post types on tag or category pages. ### What would be required before the loop to include all posts? (including custom type). **Updated:**   To add, I found this code here, which worked perfectly for the first part:               add_filter('pre_get_posts', 'query_post_type');     function query_post_type($query) {       if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {         $post_type = get_query_var('post_type');         if($post_type)             $post_type = $post_type;         else             $post_type = array('post','cpt'); // replace cpt to your custom post type         $query->set('post_type',$post_type);         return $query;         }     }      Second question still remains though: ### Is there a way to allow readers to filter by post type? So either of the following would work..   * `example.com/tag/blue?post_type=custom`   * `example.com/tag/blue?post_type=post`


Is it possible to not receive email notifications for comments?

I created several blogs. Two are sites I maintain but others are sites I created for other people and I retain administration access to them just in case they need me to go and fix some page, but I don't want to receive notifications every time they have a new comment waiting for moderation. Is there a way in WordPress that while being an administrator of a blog, to not receive the email notifications for some blogs and still get them for some other blogs?


How Can I Securely Implement a Password-less Login Feature?

Just posted a new plugin: No More Passwords I currently have it tagged beta because logging into a platform is a sensitive issue and I don't want to release something that may have security holes. So here's my query: Is is secure? I've done the following to ensure security:   1. Username/password are never passed back and forth, only the unique hash.   2. Hash is removed from the database once it’s used, old hashes that haven’t been used can’t be unless the database is hacked, but then you have bigger issues.   3. All database queries of the hash have been escaped to prevent XSS attacks.    4. nonce added to ajax call.   5. nonce and confirmation added to on mobile end to prevent CSRF attack. Here I have a complete description of how it works. Next version I hope to implement oauth via twitter, since iOS now has it worked in... Thanks for your input in advance. Edit: I decided that as an added layer I would add a sessionID check to make sure that it's the same browser logging in as the browser that initiated the QR code login.


Taxonomize taxonomy terms?

I want to register taxonomies that apply to taxonomy terms (in addition to posts). I believe this is possible because posts and terms are both WP objects. What steps are needed to achieve this? Because taxos are mainly geared towards posts, what needs to be done differently to achieve this? On "edit term" pages, how can I get the editing boxes to appear like they do in posts? Relevant core files:   * wp-includes/taxonomy.php   * wp-admin/edit-tag-form.php


twentyeleven_content_nav hook no longer outputs navigation link after 3.5 upgrade

After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins.                                       <?php if ( $wp_query->have_posts() ) : ?>                                      <?php twentyeleven_content_nav( 'nav-above' ); ?>                                      <?php /* Start the Loop */ ?>                                              <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>                                              <?php get_template_part( 'content-beers', get_post_format() ); ?>                                      <?php endwhile; ?>                                      <?php wp_reset_query(); ?>                                      <?php twentyeleven_content_nav( 'nav-below' ); ?>      Live site page


Jquery on custom-field backend

I need some help because I want to use some jquery (and css probably) on some custom fields on post edit screen. What I need exactly is to make , and . magically apear when user types a number: types 100, jquery makes it 1,00 and so on. The custom field I created using the plugin Types and it's named wpcf- imovel-preco. I have no clue about using jquery to manipulate elements on backend :(, that alone would be great help, so i know where to start from!


Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?

Is wordpress capable of having hierarchical taxonomy and hierarchical custom post types in one permalink ? I would like to do the following: **tax-1/tax-2/cpt-1/cpt-1-post/cpt-2/cpt-2-post/** in other words: **continent/country/travelog/travelog-post/videos/video-post/** or in a real case where "a-day-at-the-beach" is the travelog post and "sand- in-my-trunks" is the video post: **europe/spain/travelog/a-day-at-the-beach/videos/sand-in-my-trunks/** I have 4 custom post types that would always be at the level of cpt-1 and 3 custom post types (videos, photos, sketches) that would always appear at the sub level of cpt-2. When complete the site will have roughly 4000 posts in total. I'm hoping there is a plugin or set of plugins to help achieve this, but so far I've not found that magic combination. If not, can this permalink structure be custom coded with url re-writes and REGEX ?


Wrapping the_content() in Schema articleBody tag?

I am trying to put `the_content()` inside `<meta itemprop="articleBody" content="`(content here)`">`. But if I just put `<?php the_content() ?>` in there, it doesn't work, image goes, structure gets mis-aligned, and `">` appears after the content. Any ideas? Edit: I don't know why this was put on hold for not fitting in the Wordpress scope.. the_content() is a Wordpress function, I was clearly having trouble with structuring/SEO for my Wordpress site.


Plugin Creation: Overriding upload_max_size and post_max_size

I'm trying to write a plugin script that involves the user uploading a large file. To cope with this I need to alter the following settings:   * post_max_size   * upload_max_size If I alter these in php.ini it works as intended. However, it I try the following from within my plugin code, it doesn't take affect:               @ini_set( 'upload_max_size' , '100M' );     @ini_set( 'post_max_size', '105M');      I don't really want to have to talk the user through editing of either php.ini or a WordPress config file. Ideally I'd be able to perform it for them from within the plugin. Does anyone know how this can be achieved? Cheers.


Validating a new user registration field

**What I'm trying to do:**   * Add new user meta fields that can be updated when the user edits their profile   * Validate them correctly when the form is submitted **What I've done:** I have successfully added the fields to the user editting form and have them being updated to the options database as follows:               public function setup_user_meta() {         // Show the fields when editing or showing         add_action('show_user_profile', array($this,'show_user_meta'));         add_action('edit_user_profile', array($this,'show_user_meta'));         // Update the fields         add_action('personal_options_update', array($this,'process_option_update'));         add_action('edit_user_profile_update', array($this,'process_option_update'));     }      .               public function show_user_meta($user) {         ?>
Player Information

                 Description	                 <textarea name="cuhc-description" id="cuhc-description" rows="5" cols="30"><?php echo esc_textarea(get_the_author_meta('cuhc-description', $user->ID)); ?></textarea>

          <?php         }      .                   public function process_option_update($userid) {             update_user_meta($userid, 'cuhc-description', ( isset($_POST['cuhc-description']) ? $_POST['cuhc-description'] : '' ) );         }      **What I want:** This works, however I have a number of different fields and I want to validate them in `process_option_update()`, eg: checking they're a number and if not returning an error to the user. How do I tell Wordpress there is an error and not to continue to act on the form? And where do I echo or send the error(s)? Wordpress also appears to use javascript validation within the user update page - how do I piggy-back onto this instead of doing my own one?


Generate fixed image sizes for different pages, eliminate sizes during upload

I've built a few sites in Wordpress and in general I'm quite pleased with all the possibilities it has developed lately. There's one main thing that is utterly confusing for end users; the sizes they have to choose when using an image. They really do not understand the concept of pixels, and then they also forget to pick a size anyway. It's very demanding. Coming from CMS systems such as Expression Engine, I am used to the end user uploading the file and the sizes are generated using ImageMagick (or similar) through the template/theme. So he'll never have to choose a size. This also has the advantage that images are constantly the same in sliders etc. So is there a way of simplifying this procedure? No size options, resizing only when needed on a page and in the exact size.


Ability to only view (not edit) other user's personal profile information

I have created 2 roles, `Center` and `Student`, for my WordPress website with different capabilities using members plugin. I want the student role users to be only able to view and edit their personal profile information and I achieved this by granting them the read capability. Now the issue is I want the Center role users to be able to list and view student role users personal profile information without being able to edit them. I have granted the Center role three capabilities: `read`, `list_users`, `edit_users` with this I am able to list all users as I wanted to, I am able to view personal profile information but with the ability to edit. I know that with `edit_users` editing ability will come, but I want to know how to limit it to view or ready only, or is there any other way out. I don't want the Center users to be able to edit student users personal information, they should just be able to list and view the information. I am new to WordPress and I am loving it.


Dismiss Bootsrap modal outside modal div

this is my first post here so i am sorry in advance if this is a niewbie question ... ( i am a civil engineer not a wordpress developer... :( ) I have added a bootstrap modal dialog in my wordpress website...everything works fine but when clicking elsewhere or pressing esc the modal dialog is not dismissed the code in loop is:               <a href="<?php echo get_childTheme_url(); ?>/modal.php?ID=<?php the_ID(); ?>" data-toggle="modal">
...
      the javascript is               $(function() {            $('[data-toggle="modal"]').click(function(e) {              e.preventDefault();              var href = $(this).attr('href');              if (href.indexOf('#') == 0) {                $(href).modal('open');              } else {              $.get(href, function(data) {                $('
' + data + '
').modal();                   });              }            });          });      and the external modal.php is               <?php if (!function_exists('get_option'))     require_once('../../../wp-config.php');?>
          ×
Modal header 2

                    <?php          $post_id = $_GET['ID'];          $queried_post = get_post($post_id);          $title = $queried_post->post_title;          echo $title;          echo $queried_post->post_content;          ?>

          Close
      Can anybody help undestand why clicking outside modal or pressing esc the modal dialog is not dismissed? Thanks in advance


Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?

I'm in the process of creating a leveled tutorial structure in WordPress and want to build it so that it sets up the front-end with no code needed from the user. So far, I have a custom post type called 'tut_page' that has a metabox for custom taxonomy called, 'tut_group' and terms can be added via the taxonomy metabox. For my register_taxonomy, the value for 'hierarchical' has been set to true. So I want levels, however I don't want more than two deep. I know that I can choose how many levels of terms to display in a template, but is there a way where I can just prevent users from creating terms that are deeper than two levels from the taxonomy metabox? Here's what I have in functions.php for registering the taxonomy:               function create_tutorial_topic() {         register_taxonomy(             'tut_group', //name of taxonomy             'tut_post', //object type e.g. our post type             array(                     'labels' => array(                     'name' => _x( 'Tutorial Group', 'taxonomy general name' ),                     'singular_name' => _x( 'Tutorial Groups', 'taxonomy singular name' ),                     'search_items' =>  __( 'Search Tutorial Groups' ),                     'all_items' => __( 'All Tutorial Groups' ),                     'parent_item' => __( 'Parent Tutorial Groups' ),                     'parent_item_colon' => __( 'Parent Tutorial Groups:' ),                     'edit_item' => __( 'Edit Tutorial Group' ),                     'update_item' => __( 'Update Tutorial Group' ),                     'add_new_item' => __( 'Add Tutorial Group' ),                     'new_item_name' => __( 'New Tutorial Group' ),                     'menu_name' => __( 'Tutorial Group' ),                 ),                 'rewrite' => array( 'slug' => 'tutorial-group' ),                 'hierarchical' => true, //this is true but I only want two levels deep             )         );     }      I would also like to build as much this as much as I can myself without having to use a plugin. I tried searching on this site and found questions about limiting the number of terms, but not hierarchy levels. Thanks for any tips in advance!


Mobile theme not showing correct page after custom re-writes

I have tried a few different Mobile Theme Plugins for WordPress. My clients site requires we use a separate theme for Mobile visitors instead of a nice responsive theme. I am running into the same issue with all the Plugins that I have tried though. My `/blog` page always shows the Mobile theme, even if I have a cookie set to view the desktop theme, so viewing in a Desktop browser or mobiles, this 1 particular page always ends up showing the mobile theme which is a huge problem. So to explain how my `/blog` page is different from other pages I will explain... I have custom re-write rules which makes all `Page post type` pages end with a `.htm` My `/blog` page is also a Page post type, however this `/blog` page has custom re-writes, which makes it work without the `.htm` that all the other Page post types have. So in short all my Post of the `Page Post Type` end with `.htm` **EXCEPT** my `blog` page which is the only page with the problem of showing the proper theme with the Mobile plugins. Below is the code used for the `/blog` page custom re-writes...               function custom_rewrites(){         add_rewrite_rule('blog', 'index.php?pagename=blog','bottom' );         add_rewrite_rule(             'blog/page/([0-9]+)?$',             'index.php?pagename=blog&paged=$matches[1]',             'top'         );     }     add_action('init','custom_rewrites');      And below is the code that makes my `Page Post Types` use the `.htm` extension...               /* Add .htm extension to Page URL Links */     add_action('init', 'htm_page_permalink', -1);     function htm_page_permalink() {         global $wp_rewrite;         if ( !strpos($wp_rewrite->get_page_permastruct(), '.htm')){             $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm';         }     }      I am currently using this Mobile Plugin http://wordpress.org/plugins/any- mobile-theme-switcher/ Another unique issue, the `/blog` page that ALWAYS shows the Mobile theme, well it works as normal and shows the proper theme is you are logged into WordPress, so only users that are logged out have the problem of always seeing the mobile theme on this page. Also if I type into the URL `/blog.htm` instead of removing the `.htm` on the blog page, then it also shows the correct theme. **Main Issue** The WordPress site has 2 themes, a Desktop theme and a Mobile theme, it uses a Plugin to detect mobile and show the correct theme. However my custom re- writes seems to be messing this up because my `/blog` page ALWAYS shows a Mobile theme, regardless if you are viewing the Mobile or Desktop theme for the site. I realize this is pretty complex but I am hoping someone might know of a simple fix I might just be overlooking. Also the Custom re-writes and all custom functionality is in a Plugin so that it should work with either theme. If anyone has any ideas based on this information, please do share, I am at a loss here and running out of options fast. After playing with this all day and making changes to try an improve this, right now my `/blog/` page shows a list of post when I view the blog page or view an actual Posts under the blog, they all show the same page which is a mobile view and lists recent posts


Is there a good Q&A platform to integrate into WordPress?

I think my audience is more capable of answers each others' questions than I am. I need a system for them to do that and I'd like it to integrate with WP so I could use their existing usernames and accounts. Do you know of a good solution?


Can i do plugin commits directly from a plugin folder inside an installation using the Trunk SVN

I have several virtual hosts setup, three of them pull files via SVN when needed(though only the trunk folder actually **needs** this), using SVN for other versions make for easy patch creation, or easy file replacement if i hack a core file. ![enter image description here](http://i.stack.imgur.com/zlOLa.jpg) My question is whether i can checkin a plugin from directly inside the plugins directory? So take this plugin located in `wp-content/plugins/post-ui-tabs` for example. ![enter image description here](http://i.stack.imgur.com/xRx0t.jpg) Can i use that folder to house my WordPress.org plugin or does my plugin's folder need to mimic the directory structure of the SVN, eg..   * brances/   * tags/   * trunk/ **UPDATE:** Thanks for the feedback guys! All helpful in getting to understand local vs remote directory structure. I've got my plugin up in the repo now, see here.   Post UI Tabs Direct answer to my question, was Yes, i can do commits directly from my plugins folder, i simply have a typical local structure of `wp- content/plugins/myplugin` which is just a checkout of `http://svn.wp- plugins.org/myplugin/trunk`. I commit directly to trunk, then when i want to push a new version, i branch onto a tag(do that directly in Tortoise) and update the readme.txt stable tag to reference the new tag, ie. the operation creates the remote `http://svn.wp-plugins.org/myplugin/tag/VER` with all my files, and makes that available to uses, whilst my local working copy remains on trunk(i'll blog about it in the future when i've had more practice). Easier then i thought!... thanks for all the advice guys.. all valuable pieces of information, Andy i felt your answer helped the most, so i'm giving you the accept, everyone else i still really appreciate your help, unfortunately i can only accept one answer... but thank you all the same.


Last comment page first with full number of comments?

I use paged and threaded comments with:   * 10 comments per page   * the last comment page first   * the newest comments first If there are 21 comments total, the first page only contain 1 comment - the newest. How do i get the newest 10 comments always showing on the first page? ~~I'm using WordPress 3.0.3.~~ Edit: Upgraded to 3.1, the problem still exists... Edit: Forgot to add the code I'm using. I use a callback for the listed comments, here goes:               function mytheme_comment($comment, $args, $depth) {     $GLOBALS['comment'] = $comment; ?>     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">         <div id="comment-<?php comment_ID(); ?>" class="comment">                  <?php if(function_exists('hkTC_comment_title'))                 hkTC_comment_title($comment->comment_ID,'','');             ?>                  <?php comment_text() ?>                                   Skrivet av:                 <?php                 $commentAuthID = get_comment(get_comment_ID())->user_id;                 echo the_author_meta('first_name',$commentAuthID)." ";                 echo the_author_meta('last_name',$commentAuthID);                 ?>                 kl. <?php echo get_comment_time('H.i'); ?>, den <?php echo get_comment_date('j F Y'); ?>
                 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

         <?php }      The hkTC_comment_title function is from this plugin that I'm also using: http://wordpress.org/extend/plugins/hikari-title-comments/ But that shouldn't mess with the number of comments I think. Edit: This is my custom template used to display the page with the comments: http://123.writeboard.com/4x2m38ifvnkrct7l


Multisite wp-admin goes to blank screen after forwarding URL

i have wordpress multisite setup on my LAMP here at home (static ip address) Using my ip in any browser it seems to work flawlessly (i have four subdirectory network sites running on it) This evening i went over to one of my domain registrars and forwarded the domain name to my static ip address (clone method). unfortunately, if i navigate to my wordpress site using the URL/wp-admin, i cannot access the dashboard on any of the network sites (it just shows a blank screen in the browser). The various networked sites front ends appear to be working normally although the login meta doesnt work (its does absolutely nothing...as if there's no hyperlink) So essentially, static ip address method of getting to multisite works fine... URL forwarding = no login to dashboard using meta or wp-admin... but everything appears to work on the front end any ideas?


How to remove .html permalink without every post getting 404?

While there are lots of posts about adding '.html' to your permalinks, I can't find anything about removing it. I changed permalinks from how the previous volunteer set it up (/%category%/%postname%.html) to remove '.html' (/%category%/%postname%/), but now posts are all getting 404 errors. What's the right way to do this if I want to remove all the '.html' extensions without the errors? Would the redirection plugin be causing the problem?


Add a notice to users upon first login to the admin area

I'd like to give users a little welcome message on their first login to the admin area. Once they hide the message it should not appear again. I noticed admin_notice is a hook but don't know where to start. Thanks.


Additional image sizes are not being generated

When I upload an image through the admin interface, the image is only saved at full-size. The other sizes are configured to their default values in Settings > Media. The automatic resized versions are not being generated. I have a feeling this is due to not having a specific PHP extension installed/enabled, but I don't know what extension WordPress uses or how to install/enable it.


Editing the Comment Reply Link

Just found this site via the WP-Hackers List, been using WordPress for years (make a living partially thanks to it) and never stumbled on this site! Posted this on the WP-Hackers list, but didn't find a solution. I know WordPress 3.1 has removed the nofollow attribute from the comment Reply link (WordPress 3.1 beta looks good), but was working on something theme wise that should also work with removing the nofollow attribute from the link for WordPress 3.0.3 and below, but can't get it working. from /wp-includes/comment-template.php                } else {       $link = "ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text";      }      return apply_filters('post_comments_link', $before . $link . $after, $post);      In WordPress 3.1 rel='nofollow' has been removed from the above code. I'm trying to achieve the same at theme level for WordPress 3.0.3 and below. Basically adding this code to the comments loop as a test works:               $comment->comment_content = str_replace('nofollow', 'Test One',$comment->comment_content);      This removes the text nofollow from a comments body. I tried               $comment_reply_link->reply_text  = str_replace('Reply', 'Test Two',$comment_reply_link->reply_text );      As another test to replace the anchor text of the Reply link to confirm I'm on the right track. Didn't work. and               $comment_reply_link->link  = str_replace('nofollow', '',$comment_reply_link->link );      to delete the nofollow part of the rel attribute. Didn't work either Tried a variety of permutations with no joy. Any ideas? David


Offset posts with random order

I'm trying to have five advertisement locations, each pulling posts from the same custom post type, but also loading randomly. The only problem I have with my code below is that it will sometimes duplicate the posts shown. Is there a way so that all 5 advertisements display a random advertisement post without duplicating? Here's one of the banners:
     <?php query_posts('post_type=advertisement_posts&offset=1&orderby=rand&showposts=1');?>          <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     <?php $advert_url = get_post_meta($post->ID, 'rba_advert_url'); ?>     <?php $thumbnail_id = get_the_post_thumbnail($post->ID);     preg_match ('/src="(.*)" class/',$thumbnail_id,$link);     if(!empty($thumbnail_id)) {     $image_path =  thumbGen($link[1],234,116,"crop=1&halign=center&valign=center&return=1");     $image_all = get_bloginfo('url').$image_path;     $my_image = array_values(getimagesize($image_all));     list($width, $height, $type, $attr) = $my_image;     }     ?>         <?php if(has_post_thumbnail()) : ?>         <a href="<?php echo $advert_url[0]; ?>" target="_blank">         <img src="<?php echo $image_path; ?>" alt="<?php the_title(); ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"/>                  <?php endif; ?>          <?php endwhile; ?>     <?php endif;?>     <?php wp_reset_query(); ?>
      Any ideas?


Hover/Zoom on Lightbox gallery

Is there a way to hover/zoom on the larger image in a lightbox gallery. I am using Lightbox Gallery Manager from Raygun and have several galleries on a page. Once the lightbox gallery is opened, I want to be able to zoom in on parts of the image to see more detail. Here is the webpage that I am building http://tandcupholstery.com/customer-restorations/. I have the lightbox galleries working, but once the larger image opens I want to be able to zoom in.


Path for contact form file

I have a php contact form that I use with all websites, so ideally I want to avoid using a plug in. The files used include: • contact.php - A file with php/html write up which displays the form fields. • contact-form.php - A file that contact.php connects to to send the information. I've created the equivalent of contact.php as a static page in the Wordpress login. The code within contact.php which connect to contact-form.php is as follows:               <form method="post" action="/contact-form.php" >      What I would like to know is how I would connect to this file in the instance of Wordpress - locating files in Wordpress is something which has always confused me... Thanks


WP_Query orderby not working with meta_value_num and menu_order

I have made a custom post type (sidebar_element) which are shown on sidebar. On each sidebar element admin can choose where in sidebar should that element be shown, ie. 'top', 'middle' or 'bottom', and that the value is saved in meta field. Meta values for those alignments are 30, 20 and 10. Now, if there are multiple sidebar elements with same alignment then they should be aligned by their menu_order value given. This is how I'm trying to achieve all that, in my sidebar.php               $sidebarElems   = new WP_Query( array (                             'post_type'         => 'sidebar_element',                             'posts_per_page'    => -1,                             'meta_key'          => 'sidebar_element_meta_alignment',                             'orderby'           => 'meta_value_num menu_order',                             'order'             => 'DESC' ) );      This however isn't working. Elements get sorted first by `meta_value_num` **ascending** and then, correctly, by `menu_order`. If I delete the `menu_order` from `orderby`, `meta_values` gets properly ordered. This thing is driving me crazy! Please help. Thanks. **EDIT**   Here's the SQL Query generated, when `var_dump($sidebarElems)`               SELECT XXX_posts.* FROM XXX_posts     INNER JOIN XXX_postmeta ON (XXX_posts.ID = XXX_postmeta.post_id)     WHERE 1=1 AND XXX_posts.post_type = 'sidebar_element' AND (XXX_posts.post_status = 'publish') AND (XXX_postmeta.meta_key = 'sidebar_element_meta_alignment' )     GROUP BY XXX_posts.ID     ORDER BY XXX_postmeta.meta_value+0,XXX_posts.menu_order DESC      **ANSWER**   Found an answer, check below


Add read more to the_content

Hi I have a custom post type that i've truncated on the archives pages using this:               function limit_the_content($content){       $word_limit = 35;       $words = explode(' ', $content);       return implode(' ', array_slice($words, 0, $word_limit));     }      How would I add a read more and a link to the end of each post. Thanks in advance.


User-friendly link to attached images for a certain post?

I have set up a slideshow running on the front page of my site that runs on images attached to a page called 'Home'. I would like to be able to adjust its contents and order from the admin area. And lo, I can do this, by going to the 'Home' page in pages, clicking on the Media Library, going to the 'Gallery' tab and reordering/editing each of the attached images. But this is not very convenient for the person who will use the site. Can anyone recommend a plugin that allows for very simple management of attachments for a given post? Even if it's just a link I can place it in a metabox on the Dashboard and they needn't follow the above tortuous route to get to where they need to be. Thanks!


Meta boxes not showing up

Okay so I'm trying to render a meta box. This is what I have so far, trying to keep it as basic as possible:               add_action('load-post.php', 'ad_templates_callback' );     add_action('load-post-new.php', 'ad_templates_callback' );          function ad_templates_callback(){         add_action('add_meta_boxes', 'ad_templates_add_meta_box');         add_action('save_post', 'ad_templates_save_post');     }          function ad_templates_add_meta_box(){         add_meta_box( 'ad_templates', 'Template Options', 'ad_templates_render', 'page', 'normal', 'default');     }          function ad_templates_render($object, $box){         wp_nonce_field( basename(__FILE__), 'ad_templates_nonce' );         global $post_id;         ?>             <p>                 balblabl test             </p>         <?php     }     function ad_templates_save_post(){         //nothing     }      I have no idea why, but it doesn't show up on either the New Page or existing Page pages. I've tried it with removing the 'load-post.php' hooks and I've tried it with using Posts instead of Pages. I've copied this code from an earlier WP theme I've created (which successfully shows the boxes), with a slight edit to the theme slug. So somewhere, somehow I'm missing something.


make diffrent template on last six post published

I wanted to make last six posts different template from other posts but I can't get it work below are my loop code inserted on my index.php               $last_no_of_posts = 6;     $ctr = 0;          while ( have_posts() ) { the_post();              if ($ctr < $wp_query->found_posts - $last_no_of_posts) {           // require special template           get_template_part( 'loop', 'special' );        } else {           // regular template           get_template_part( 'loop', 'index' );        }        $ctr++;          }


Why max-width:97.5% on content images?

Is there a specific reason why we can find max-width:97.5% instead of 100% in common themes such as Twenty Eleven?