Restrict access to non-wordpress section of site with user roles?

Is it possible to limit access to a page using wordpress user roles that isn't included in the wordpress install. For example I have a CS Cart install with only a couple of products but I need to limit access to these pages to certain users. Can I add something in to my CS Cart install to call on Wordpress to be able to limit access if the user is just a subscriber?


How to get future ID for post which haven't been created yet?

**Calling Post ID:** Lets go first with calling post id definition :) This name i actually find inside a core file `wp-admin/includes/media.php` which means for the post you requested the media upload. Media gets attached to the that post which the media uploader gets called. **Question:** Well, for new post (when you click "add new post" or "add new cpt" and you open up `wp-admin/post-new.php` page. You will notice there is a post id already assigned to the possible new post. To check hover over the media upload button and notice the url. ![media upload](http://i.stack.imgur.com/klUkl.jpg) So, **how to I find the`post_id` of the possible post?** I am trying to find out how to get that post id and searching through core file with no luck. Appreciate your help :) **Update:** Parhaps my question was little missleading. As i did not said where i am going to use the code. I am making a front end user dashboard where I need to get the id not backend admin panel, the image was for demonstration purpose. Going to use the code like on this question Image uploader with "Set Featured Image" link on front end


Toggle option in sidebar widgets

I would like to use toggle option in my sidebar widgets. But my sidebar widgets not generating unique id. This is my register sidebar code.               register_sidebar(array(             'name' => 'Main Sidebar',             'before_widget' => '
',             'after_widget' => '

',             'before_title' => '
',             'after_title' => '

'         )      This is how i'm getting output

Widget Title

            Widget content

      I mean `%1$s` not working in `after_title`. I want to use unique id. So can anyone give me some tips to make it work? Thanks


Forward an old url rewrite scheme to a new one?

I have the following url rewrite for custom post type:               add_rewrite_rule(         'event/([0-9]+)',         'index.php?post_type=event&p=$matches[1]',         'top' );      Due to a site structure change, I'll be moving this from `/event/id` to `/workshop/event/id` like below:               add_rewrite_rule(         'workshop/event/([0-9]+)',         'index.php?post_type=event&p=$matches[1]',         'top' );      How do I return HTTP 301 on the original url scheme, from within a wordpress plugin?


How to use Plupload in themes

I am developing a theme which needs uploading from front-end. I want to integrate plupload in my theme while keeping in mind that:   * Uploading will be handled upon form submission, and not from the plupload regular method. This means that I just need the design of plupload, and not the uploading functionality. After selecting the files, when I submit the form (containing selected files and other information), I should be able to grab all the form info (including files info) in the target page. E.g. In user profile page, I want to update my avatar along with my other information. Any help would be appreciated.


the_password_form functions not working together

I needed two functions on my wp-site. First I needed to change the text of password-protected-page so I picked up this code straight from this article on wordpress codex. and it works beautifully.               function my_password_form() {         global $post;         $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );         $o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">         ' . __( "
Please get in touch with us on ######## and get a password.
" ) . '         ' . __( "Password:" ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />         </form>         ';         return $o;     }     add_filter( 'the_password_form', 'my_password_form' );      Second I needed to show an error message if someone puts a wrong password in the password-protected-page so I picked up another solution provided by @toscho from here at wpse and it works like charm too.               //ERROR MESSAGE FOR PASSWORD PROTECTED POSTS/PAGES     add_filter( 'the_password_form', 'wpse_71284_custom_post_password_msg' );     function wpse_71284_custom_post_password_msg( $form ) {             // No cookie, the user has not sent anything until now.         if ( ! isset ( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) )             return $form;              // We have a cookie, but it doesn’t match the password.         $msg = '
WRONG PASSWORD.
';         return $msg . $form;     }      The issue is they do not work together for some reason. To be specific, the first code from codex works regardless of the second code commented out or not. But the second code block that pertains to error message does not work at all with the first one present. Needless to mention that both of these codes sit above one another in the functions.php. Just so you know I am using the latest wp-3.7 and testing this in live server. What am I missing, please enlighten me. thanks in advance.


Help post permalink

How can I change the `-` to a `+` in the URLs, automatically?               http://website.com/post-name/     http://website.com/post+name/


Write query according to post_meta

I have a front-end form which stores some data related to that post and adds that post to their `favorite` posts when the user clicks on it. So now my concern is when the user clicks on the favorite posts template it should only see their favorite post.               $args = array('posts_per_page' => 20, 'paged' => $paged, 'post_type' => 'post', 'post_status' => 'publish' );      This is my query right now. How can I modify it that it only show those post which the user mark as favorite?               add_post_meta($postid, 'favpost'.$userID, $postid);      This is how the user marks their favorite post. Can anyone guide me on how I can get my data base on `post_meta`?


Twenty Thirteen get_sidebar Question

I've been looking at Twenty Thirteen's code structure and thought I could learn a thing or two about theme development. There's something that I haven't found an answer to: Twenty Thirteen's widget areas are called by just using `get_sidebar()`. However, there are 2 sidebar files in the theme's folder - sidebar-main.php, sidebar.php. From what I understand, sidebar-main.php can be called by defining the parameter of `get_sidebar('main')`. In Twenty Thirteen's case, I see no code which calls that, yet `is_active_sidebar('sidebar-1')` is executed. **How does it call sidebar-main.php without defining the parameter?** Another thing I've tried doing is switching the file names. The one with 'sidebar-2' to sidebar-main.php and 'sidebar-1' to sidebar.php. Everything screws up! The right sidebar widget isn't in place and the footer widget doesn't even show. ![enter image description here](http://i.stack.imgur.com/DfYVY.png) **How is Twenty Thirteen calling it's sidebars?** Thanks in advance.


Plugin permissions for Editor role

I've added a plugin called Orbisius Simple Notice but I notice this applied to several plugins I have installed. The plugin works fine when logged in as an Admin. However, my clients who manage the site use accounts set to Editor roles. When any of the Editor accounts try to access the options page for the plugin, they get the following message: "You do not have sufficient permissions to access this page." I use User Role Editor to ensure they have permissions to edit plugins. However, I know the issue is not related to this as I enabled all permissions as a test and I still got the above error. So I figure it's hardcoded into the plugin. Source for the plugin: http://pastebin.com/UhrvkiXv The only bit I saw that seemed appropriate was:               function orbisius_simple_notice_setup_admin() {     add_options_page('Orbisius Simple Notice', 'Orbisius Simple Notice', 'manage_options', __FILE__, 'orbisius_simple_notice_options_page');      But the users have manage_options enabled. I tried changing to edit_pages etc. but still no luck. Any ideas?!


How to sort product by a merchant in woocommerce admin?

I am building multi merchant shopping site where no of merchant add their product. I am using 'User Role Editor' plugin for assigning a role. There is a super admin who can view all the merchant's product in admin section. I want to sort this product by merchants. How it is possible. Please help anyone.


query_posts with a custom post type, a meta_query and sorting by post date?

I've searched the archives and found questions _similar_ to what I need, but haven't found exactly what I want. I've got a bunch of products that are sorted by a meta_key of country, and I'd like to be able to allow the user to sort either by the post title (product name) or the post date (how long the product's been in the database. What I'm experiencing is that if I select the country to display, that works properly, but will _only_ order by post title. If I select "all countries", which does not add a meta_query, sorting by date desc works. Here's the code I've got:               $meta_queries = array();          if ( $_REQUEST['country'] ) {         $meta_queries[] = array(             'key' => 'country',             'value' => $_REQUEST['country'],             'compare' => '=',         );     }          $sort_by = 'title';     $sort_order = 'ASC';     if ( $_REQUEST['sort_by'] == 'new_products' ) {         $sort_by = 'date';         $sort_order = 'DESC';     }               query_posts(array(         'post_type' => 'currency', // custom post type         'paged' => 1,         'orderby' => $sort_by,         'order' => $sort_order,         'meta_query' => $meta_queries,     ));      TL;DR, is there a way to have a meta_query AND sort by the post date?


Autolinking keywords in text with tags

Sometimes in my posts I use the keywords that exists in my tags and categories list. Is it possible to automatically link the keywords in texts with the tags and categories? Or should do it manually ? I will use this in my SEO practices. Thank you


Redirect Site Geologically

I am using WordPress mu and need to redirect my site based on the users geo location. For example if you go to yahoo from the US it will goes to yahoo.com, but if you visit the site from India it goes to in.yahoo.com or in the UK to uk.yahoo.com, etc. Is there a way to have my WordPress do this?


Best Way to Leverage Custom Post Type Related Content and Consider SEO

I'm doing a real estate project for a client. I've created a custom post type called "communities" to list new construction communities in her area. I also want to have deeper sub pages but I would like to keep the URL structure in line with: /communities/tall-pines-development to show something along the lines of: /communities/tall-pines-development/site-plan, /layouts, /clubhouse, etc. I see that child pages is one consideration but I'm not quite sure how to implement them on a custom post type. Since I already am in a custom post type I'm not sure how to go deeper and keep the logical structure of the URL and enable something like breadcrumbs which are also great for SEO. Hope that makes sense. I was thinking about building a jQuery tabbed navigation on the single-communities page template, but for SEO purposes I think separate pages would be more optimal. Was thinking taxonomies at first, but how would I show the additional content I need including a featured image, image(s) and content? Hope that makes sense. Burning the midnight oil and the brain is slowing down. Just isn't coming to me. Thanks.


How can I create a master archive?

I'm trying to create a master archive, and I thought maybe someone could help me out. The way I have it set up now is pretty simple. I have author archives, which simply list every post by a certain author, as seen here: http://www.viiinothing.com/author/ryan/ What I'd like to do is create a master archive that looks identical to this, except it displays every post by every author. I've tried a variety of ways to make this work, including query_posts and get_archives, but all I've been able to accomplish is show a list of the last ten posts . . . but then the page numbers and "Older" and "Newer" and page numbers won't show up at the bottom (see link). I hope that makes sense. I realize _why_ it's not doing that, but I still can't figure out how to get it to work like the author archives. Thank you!


Allowing periods in usernames

I have a multi-site installation of wordpress currently running, and I am having some problems with user registration. Currently, I use an external authentication plugin (similar to LDAP i guess) and I use this to validate usernames/passwords. For this to work, every user is first added to the Wordpress list of users, and the plugin checks against this list. The problem is that my organization allows periods inside of a persons username (eg, john.smith). Wordpress is not allowing me to enter john.smith as a username into the system (only allows a-z characters). Is there any type of workaround for this? I would rather not edit the wordpress core as thats a horrible practice


Fancybox Iframe freezing before loading

So my wordpress fancybox iframe is kinda malfunctioning. When I click the link, the fancybox is triggered and a small rotating image shows and stops for a few seconds, then the iframe shows. Also, sometimes the iframe loads on the bottom of the page?


uninstall.php file in Plugin to clean DB

I am aware that WordPress provides Plugins a nice way to clean up the db if the Plugin is deleted by providing the `uninstall.php` hook. You just have to place the cleaning code and it works. But my question is, I have seen a couple of Plugins which is using functions defined in their Plugin file inside the `uninstall.php` file. My understanding is that if the Plugin is already disabled and the user is deleting it after that, then these functions may not be accessible. Is my assumption correct or is there any WordPress magic which I am not aware of?


How to control which category will be picked for the slug of a post?

I'm using the permalink structure "/%category%/%postname%/". What bothers me is that I have posts that belong to two categories. And of course, unfortunately, Wordpress always picks the wrong one for the slug generation. Is there a nice and clean way of having control on which category will be chosen for the post slugs? Thanks a lot!


Share content between two different sites in same domain

I am trying to accomplish something weird... I have a client who wants to have two different sites to share the same content (some post types and pages). I warned him about SEO problems, but he still wants to do it. I have searched a lot, but haven't found a solution. Does anybody have any idea for make this work? Best regards.


A way to sort WordPress themes?

I want to write a plugin which can sort themes into categories. For example I have Categories 3 themes in Business as subfolder from /themes/business 7 themes in Nature /themes/nature 2 themein in private /themes/private by default WordPress shows me all 12 themes in the backend. I tried to change the theme root               add_filter("theme_root","tr");     function tr($J){     print_r($J);//if yo udo this you see the main theme folder     $J="/www/wp-content/new-themes"; //folder new-themes exists     return $J;     }      but in general this does not work. Any ideas are highly appreciated.


Different posttypes for different authors

Now what I need to find a solution of is this issue: I have 8 authors, and a bunch of posts. All authors have there own adsense (or other affiliate), we wish to show the adds belongings to the authors on there OWN posts. So the author collects payment (if any) from there own posts, and only from there own posts. Is there any way to make wordpress/theme do something like that? Thanks Marius


WordPress + Magento .htaccess ReWriteRule Issue (www vs. non-www)

I have an issue I've been facing for a bit now. Moved away from it, but now I'm back and just have no idea after trying to find a solution online. It seems individuals have faced similar issues, but trying out common fixes has resulted in just 500 Internal Server Errors. I'll try to be as thorough as possible in my explanation. OK, so onto the issue. I have a site using WordPress and Magento. The WP pages are kept in a subdirectory (/about/) so when a user accesses one of the pages, the url looks like this: www.example.com/about/wordpresspage/. We have a products page that is kept outside of WP and is accessed directly, the url looks like this: www.example.com/magentoproductpage/. The issue arises when a user tries to visit the non-www url. If I remove the "www." from the magento page url (example.com/magentoproductpage/) I am redirected to www.example.com/index.php. I know why this occurs but don't have a fix for it, yet. The more apparent issue is when trying to access a WP page without "www.". So let's say I remove that from my previous example (example.com/about/wordpresspage/) I am redirected to a 404 page, and furthermore the URL now becomes this: example.com/cgi-bin/php/about/index.php This only seems to occur in Google Chrome and not in Firefox. Obviously the idea here is that I just want to add www. to non-www URLs. Any suggestions? Thanks in advance.


get content from page through AJAX

I'm using an wordpress theme and I want to load content through AJAX inside a page. I've added this inside my **functions.php** :               function my_ajax_files()     {               wp_localize_script( 'function', 'my_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );          wp_enqueue_script( 'function', get_template_directory_uri().'/my_js_stuff.js', 'jquery', true);          }     add_action('template_redirect', 'my_ajax_files');          function get_my_comments() {                   global $current_user;         get_currentuserinfo();              echo 'Username: ' . $current_user->user_login . '
';         echo 'User display name: ' . $current_user->display_name . '
';                   $args = array(         'user_id' => $current_user->ID, // use user_id         'post_type' => 'debate'          );         $comments = get_comments($args);                   echo '
';                        wp_list_comments(       array(         'per_page' => 10, //Allow comment pagination         'reverse_top_level' => false //Show the latest comments at the top of the list       ),        $comments     );               echo '
';            }          add_action("wp_ajax_nopriv_get_my_comments", "get_my_comments");     add_action("wp_ajax_get_my_comments", "get_my_comments");      and this file **my_js_stuff.js** contains this :               jQuery(document).ready( function() {      jQuery( "#target" ).click(function() {      jQuery.ajax({      url: my_ajax_script.ajaxurl,      data: ({action : 'get_my_comments'}),      success: function() {      jQuery("#content").append(data);        }      });       });       });      Inside the page where I want to get the content from the function I have added a div with an id of **target** , but when I click on it nothing happens, I've checked also the console and I don't have any errors. What is wrong ?


How can I group posts by date on frontpage?

For example; 20 September 2014 Post 1 Post 2 Post 3 19 September 2014 Post 1 Post 2 Post 3 18 September 2014 Post 1 Post 2


Working widget does not show up in appearance->widgets

I try to add a custom widget for use outside of a normal sidebar. For that I have created class myfirst which extends WP_Widget and with appropriate function overrides.               namespace widget;          class myfirst extends \WP_Widget {     public function __construct() {         parent::__construct(                 'Myfirst',                 'Myfirst',                 array(                     'description' => 'Finally a widget',                     'classname' => 'myfirst'                 ));     }          public function widget($args, $instance) {              $title          = apply_filters('widget_title', $instance['title'] );         $before_widget  = $instance[ 'before_widget' ];         $after_widget   = $instance[ 'after_widget' ];         $before_title   = $instance[ 'before_title' ];         $after_title    = $instance[ 'after_title' ];              echo $before_widget;         if($title) echo $before_title . $title . $after_title;         echo 'Hello World';         echo $after_widget;     }          public function update($new, $old) {         return $new;     }          public function form($instance) {         if ( isset( $instance[ 'title' ] ) ) {             $title = $instance[ 'title' ];         }         else {             $title = __( 'New title', 'text_domain' );         }         ?>         <p>         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php echo 'Title: ' ; ?></label>          <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">         </p>         <?php      }     }      I add the widget in the functions.php file with this code:               function register_foo_widget() {         require_once('assets/customwidgets.php');         register_widget( 'widget\myfirst' );     }     add_action( 'widgets_init', 'register_foo_widget' );      And displays the widget using               the_widget('widget\myfirst');      I can output the content of the widget but the widget does not show up in appearance->widgets. Actually the field appearance->widgets does not show up at all. I think it has to do with the overridden function form but it does not lead me anywhere. So what is the problem here really? Thank you


Create Nested Categories On Import

WP all import trying to import data with multiple nested categories and paths.               <id>     A|A Sub|A Sub Sub|A Sub Sub Sub     A|A Sub|AB Sub Sub|AB Sub Sub Sub     A|A Sub|AC Sub Sub|AC Sub Sub Sub     </Id>      Below is a quote from WP All Import > To do this automatically you would need to create a custom function. You > would get all the categories from the post by referencing it through the > Post ID, this would get you an array of all the categories assigned to the > post. You would then go through the array and get only the lowest sub- > categories and make a list of their IDs. Once you have all the category IDs > you can replace the attached categories and only assign those lowest > subcategories. http://codex.wordpress.org/Function_Reference/wp_set_post_categories You can trigger that function through the "pmxi_saved_post" action hook, which already broadcasts the Post ID, for each of the imported posts. http://www.wpallimport.com/documentation/advanced/action-reference/" If any one could help me resolve would greatly appreciate. Im a novice.


Add custom field to post with some part of url as value

I wish to move my site from some other CMS to WP. There is no any usefull migration, export option in my current CMS so I will need to create posts again manually. I will to transfer important fields of posts on current CMS to custom fields on WP. I am thinking to create some php functions wich will add some custom field to post with some data on new WP site. Like I said there is no any useful export tool on my current CMS (mostly file system), but I can make on my current CMS post link with some added variable like this: www.my-site.com/category/subcategory/post-name?value-of-some-field Then I will crawl my own site to find and make list of links with that suffix "?value-of-some-field". After that I will update links list to new site location on WP test site like this. www.test-wp.my-site.com/category/subcategory/post-name?value-of-some-field Then I would like to use code on single.php page to check if url contain "?value-of-some-field" and if it is true to make some custom field with data "value-of-some-fields". I managed to do this successfully when I know which value I can expect, in case there is several, limited number of different values like this:               <?php     $currenturl = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];          // Look at URL     $pos1 = strpos($currenturl, "?value-one");     $pos2 = strpos($currenturl, "?value-two");     //...          // If URL has "?value-one" create new custom field and add value-one     if($pos1 == true) {     add_post_meta($id, 'my_new_custom_field_name', 'value-one', true);     }     // If URL has "?value-two" create new custom field and add value-two      elseif($pos2 == true) {     add_post_meta($id, 'my_new_custom_field_name', 'value-two', true);       }     // ...     ?>      What I need is code wich will create new custom field and add data inside it copied from url after "?" sign. For example if url is like this: www.site.com/category/subcategory/post-name?some textual description will be here program will crawl and save that link like this: www.site.com/category/subcategory/post- name?some%20textual%20description%20will%20be%20here Of course I can make some START, END markers in url if needed like this www.site.com/category/subcategory/post- name?START__some%20textual%20description%20will%20be%20here__END **What I need is code which will check if url contains something between "START__" and "__END" and to create new custom field with text between "START__" and "__END", and if it is possible to replace "%20" with space " ".** In this example to create new custom field with value "some textual description will be here"


Cherry Framework Categorys not working on custom post type

I am using the Cherry Framework. In a child theme i have added a new custom post type and set it to use the built in category and post-tag taxonomies. I have added this to my theme.ini in my child templates folder. my custom-post-type is called product. I can get the post to display using: myurl.com/product/product-slug, A listing of all products added using: myurl.com/product/ On both the listing and the product pages, everything displays as it should except the categories and tags are not displayed for the post. If i browse directly to the category or tag page: myurl.com/my-category/ no products are shown. If i switch my theme back to a standard wp theme with the same code i use for the custom post type the categories and tags work fine. I did a completley fresh install of wordpress, and reset the permalinks, but still no joy. The code for my custom post type called product:               function products_post_type() {         $labels = array(             'name'                => _x( 'Products', 'Post Type General Name', 'text_domain' ),             'singular_name'       => _x( 'Product', 'Post Type Singular Name', 'text_domain' ),             'menu_name'           => __( 'Products', 'text_domain' ),             'parent_item_colon'   => __( 'Parent Product:', 'text_domain' ),             'all_items'           => __( 'All Products', 'text_domain' ),             'view_item'           => __( 'View Product', 'text_domain' ),             'add_new_item'        => __( 'Add New Product', 'text_domain' ),             'add_new'             => __( 'New Product', 'text_domain' ),             'edit_item'           => __( 'Edit Product', 'text_domain' ),             'update_item'         => __( 'Update Product', 'text_domain' ),             'search_items'        => __( 'Search products', 'text_domain' ),             'not_found'           => __( 'No products found', 'text_domain' ),             'not_found_in_trash'  => __( 'No products found in Trash', 'text_domain' ),         );         $args = array(             'label'               => __( 'product', 'text_domain' ),             'description'         => __( 'Product information pages', 'text_domain' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ),             'taxonomies'          => array( 'category', 'post_tag' ), //uses built in taxonomys             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'capability_type'     => 'page',         );         register_post_type( 'product', $args );          }               // Hook into the 'init' action     add_action( 'init', 'products_post_type', 0);


Can I force get_option to go back to the DB instead of cache?

Is there any way to guarantee that when I call get_option I will definitely get the value from the database and not from cache?


How to sort post by custom table value

How can I sort my post by the maximum vote in custom table I have table like this:( user_votes) ![enter image description here](http://i.stack.imgur.com/1CaVa.png) here post id 315 have votted two times so I just want to sort my posts by maximum vote. I am only able to do sorting by only date as:               query_posts("&orderby=date&order=ASC");              while(have_posts()){                 the_post();                 $postData = array();      How to sort or modify query_posts based on user_votes table Thanks


Can simple Admin save options in a Multisite?

I am developing a custom plugin on a multisite installation that, unfortunately, I am not so use to work with. Tis is the problem: I need to add a field into che profile page of a user and I need that the value that will be insertered is going to be stored as user meta and also as option (inside the wp_options table). Everything works fine if I am the Super Admin, the option will be stored and I can use them later in my theme, but when I try to store the values with the `update_option()` function I am not able to do it and I cannot store the values. Here you can find my experimenting code but please notice that even if I have no problem with the function `update_usermeta()` I can't store my info in the wp_options table...               function ohw_update_field( $user_id ){         $field = 'side_banner_' . $user_id;         $side_ad = $_POST[ $name ];         update_usermeta( $user_id, $name, $side_ad );         update_option( $name, $side_ad );     }          add_action( 'personal_options_update', 'ohw_update_field' );     add_action( 'edit_user_profile_update', 'ohw_update_field' );      As you can see I am trying to use the `$user_id` in order to create an unique field in the table, probably I'll start to use an array to serialize the information in an unique field but I would like to understand why the admin of a site of the network is not able to save an option... I mean, as I read on the Codex a user should have the `manage_options` capability in order to access this database, so why is only the super admin the one who's able to do it? Thank you in advance for all the answers and have a great day!


How to cancel a custom post type query based on existing cache file

Is there a proper way to greatly restrict the query (or remove it altogether) for a custom post type `type-single.php` file? Simply stated, for reasons of speed speed speed I've cached all relevant information on that page, and the product should reference the cache file instead. If the cache file has been written, it would be better to avoid running the initial query since most/all of it will not be used anyway. Thoughts on this? I was going to use '`pre_get_posts`' but I'm not confident this is the best way to cancel the process.


How to display a sticky post inside a div?

I have a and inside it I would like to add the contents of the first sticky post. I went on codex.wordpress.org to find more about wp_query and saw this code that I could use to solve my problem:               $sticky = get_option( 'sticky_posts' );     $args = array(         'posts_per_page' => 1,         'post__in'  => $sticky,         'ignore_sticky_posts' => 1     );     $query = new WP_Query( $args );     if ( $sticky[0] ) {         // insert here your stuff...     }      What I don't know is if this is what I am looking for and if yes, what do I need to add in the if statement in order for this code to display the first sticky post inside my div? Thanks in advance!


Link Redirection issue for wp-admin

I am facing a problem when I login into the wp-admin dashboard. It is not allowing me to login with my domain name, but when I modify the url "www.example.com/blog/wp-admin" to "www.example.hostingname.net/blog/wp- admin", then it will allow me to login. What problem is occurring? I am not able to solve this, does anybody have a solution for this issue?


Localized WordPress content for different sub-locales of same language?

I have a site which serves Ireland & England. I want to move it to Wordpress. Currently all the content is the same when you visit the site & it runs off two urls, the Irish one: mysite.ie & the english mysite.co.uk I need to show different prices based on whether the user is visiting the Irish site or the English one. Currently I do something like:               $host = $_SERVER['HTTP_HOST'];      if($host == "www.mysite.ie") {      //show Irish prices     }      I don't think I can run one WP installation off 2 domains for a start. It's not multilingual, so is there a way to show all the same content except for small differences based on the URL?


wp query by search in titles only & put the posts in loop

i need to get posts by search in posts title only not search in full post & put the posts in loop to show it in a slider **Note : i need to get posts by keyword in title & put it in loop to showing it, not limiting search in all of the site** i used `wp_query` to do that but it is get posts by searching in full post "content&title"                <?php $query = new WP_Query( 's=mykeyword&cat=22,32&order=dsc&showposts=6' ); ?>      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
      <?php endwhile; ?>      <?php endif; ?>      how can i do that


How do I get W3 Total Cache not to cache sidebars?

At the moment I run PHP code in my side bars. Even though I have the following               header("Pragma: no-cache");     header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past      It still appears to serve cached content.


Can you exclude child pages of a specific parent within a navigation?

For example, I'm using wp_list_pages to display the navigation, the child pages (and their children) appearing on hover as is typical. However, I want one of these parents to _not_ display the children. Essentially I want something like exclude_children_of to work in the wp_list_pages arguments; is there a way of doing this anybody? thanks Rob


Use a function to update post meta based on other post meta

No idea how to title this so feel free to edit. I set out to create a "hotness" for my posts and to do this I used the `$ratings_score` which is stored as post_meta as a number +/- and the days ago of the post which I trimmed down to just the days. I divided the ratings_score by the days to get a number which reflects the hotness of the post. I ran this function inside the loop to get the result...               $time_ago = human_time_diff( get_the_time('U'), current_time('timestamp') );     if (strtotime($time_ago) <  strtotime('1 day')) {      $time_ago = "1";     }     $days_ago = preg_replace("/[^0-9 ]/", '', $time_ago);     $days_ago;     $ratings_score = get_post_meta($post->ID,'ratings_score',true);     $hotness = $ratings_score / $days_ago;     echo $hotness;      That works fine but what I really need to do is make this into a function in my functions.php and store `$hotness` as post_meta. I need it to constantly update itself aswell based on the changing of the days ago and `$ratings_score`. So then I can sort my loop by the `$hotness` meta_key. How can I do that?


Friendica integration using wordpress authentication

I currently have a BuddyPress community with bbPress forums and a MediaWiki based collaborative area. I'll soon be adding Friendica support for good integration with other friends Diaspora websites plus other social network integration that Friendica can provide. I basically want Friendica to use BuddyPress for authentication, single sign on. If the user is logged in on BuddyPress, they are logged in on Friendica. I may have to develop this from scratch, in which case I document what I do and post it as an answer here, but before I do that, if anyone has already done this and can post instructions on how to do it, that would be a big help.


Does anyone know how to load jquery in the footer?

I have tried every way I know about, and have read about, to move the jquery library to the footer including the following and every possible variation of the following:               function add_scripts() {             wp_deregister_script('jquery');             wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3', true);             wp_enqueue_script( 'jquery' );     }     add_action('wp_enqueue_scripts', 'add_scripts');      and               wp_enqueue_script('jquery','/wp-includes/js/jquery/jquery.js','','',true);      I'm not sure what version(s) of Wordpress these worked in but they don't work in the latest versions (3.5 - 3.7). Of course jquery can be deregistered or completely deleted from the script-loader.php file and then hard coded into the footer but the script will not work. WordPress somehow prevents it from actually loading even though the code to do so is sitting there in the html. Before anyone says this, while I am attempting to load jquery in the footer, all other javascript will be loaded afterwards so it a question of jquery dependent scripts loading prior to the library. Also, many of people will say that its not good to load core scripts in the footer which, from a best practices standpoint, may be true but this is irrelevant because Google wants it in the footer and that is all that really matters. Any suggestions will be appreciated.


Assign post type to many users

I am working on a small course engine that has a Course custom post type and a list of users. Users should apply for courses. I was thinking about the Posts 2 Posts plugin to create the relationship, but is there any straight forward way to assign many users to a single post type (course) and see only things for that specific post type? Any premium plugin that could do that without making everything really heavy? P.S. A user could attend several courses as well.


Highlight current post type when inside custom post type

I have a custom post type called: "movie"   I have only 4 movies in my movies section in the site.   Inside each movie post type I want to display all other movies in a side list like so:   * movie 1   * movie 2   * movie 3   * movie 4 so the user can navigate from each movie page to all other movies. I used this code to display the list of all of my "movie" post types:
     <?php $loop = new WP_Query( array( 'post_type' => 'movie', 'posts_per_page' => 4, 'order'=>'ASC' ) ); ?>     <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
         <?php the_title( '', '' ); ?>
         <?php endwhile; ?>
      So far it is very simple and working. I would also like to add a **"current"** class to each item in the list that corresponds to the post I am currently reading. for instance if I am inside movie 3 I see this:   * movie 1   * movie 2   * **movie 3**   * movie 4 The problem is that unlike WordPress custom menu, no "current-menu-item" or other class is automatically generated. any clue how I can accomplish that?


Can I lock down custom taxonomies on a parent term level, but not a child term?

I've created a taxonomy called "topics" which has 4 top level terms:   1. science   2. environment   3. technology   4. cant remember the last one and each of those terms will have child terms. I want to be able to lock down the top level terms but not the child term. Basically editors should be able to create as many terms as they want for each of those top level terms.. But those top level terms cant be deleted or modified. Is that possible?


Cannot login due to incorrect password right after registration?

I am using Register Plus Redux. I don't know what happened exactly but after I upgraded to 3.1.4, the password provided on registration isn't recognized. I have to go in using admin account and set the password again. This does not happen with the default registration form though. I don't where to contact the author, if this isn't appropriate feel free to delete it.


why is esc_html() returning nothing given a string containing a high-bit character?

In PHP 5.2, filter_var() sanitizes text. In WP, esc_html() sanitizes text. The former works with a high-bit character in the text string, e.g. a , but the latter doesn't. esc_html seems to be totally eating a string containing a high-bit character. Here's the example, written as a simple WP plugin:               <?php     /*     Plugin Name: bugz tester     */     class bugz_tester {          function __construct() {             if ( ! is_admin() )                 return;                  add_action('admin_menu', array(&$this,'admin_page'));            }              function admin_page() {              add_options_page('Bugz tester', 'bugz', 'edit_posts', 'bugz_sheet', array(&$this,'test_page'));         }                   function test_page() {                 ?>
             <?php             $ts = 'blah à blah';             echo "original: " . $ts . "
" ;             echo  "PHP sanitized: " . $this->sanitize_txt( $ts ) . "
" ;             echo  "WP sanitized: " . esc_html( $ts ) . "
";                            die();             ?>
             <?php         }              function sanitize_txt ( $text ) {             $san_text = filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_STRIP_LOW ) ;             return $san_text;         }             }     new bugz_tester();     ?>      Here's the output: > original: blah � blah   >  PHP sanitized: blah à blah   >  WP sanitized: I'm not obsessed with using esc_html(). But if I use instead filter_var(), the string vanishes when I add it to a WP custom field. Somehow WP sanitation is killing the string. I'm mystified. Would be grateful for a clue.


Error While Sending Comment

I'm trying to apply this tutorial to my blog. I'm using Woothemes' Bueno Theme . I'm adding this code to my theme's _functions.php_ file :               function ymc_add_meta_settings($comment_id) {       add_comment_meta(         $comment_id,          'mailchimp_subscribe',          $_POST['mailchimp_subscribe'],          true       );     }     add_action('comment_post', 'ymc_add_meta_settings', 1);          function ymc_subscription_add( $cid, $comment ) {       $cid = (int) $cid;            if ( !is_object($comment) )         $comment = get_comment($cid);            if ( $comment->comment_karma == 0 ) {        $subscribe = get_comment_meta($cid, 'mailchimp_subscribe', true);     if ( $subscribe == 'on' ) {     update_comment_meta($cid, 'mailchimp_subscribe', 'off');          /////////////////////////////////////     ///////MailChimp////////////////////     ///////////////////////////////////       $apikey   = 'MYAPIKEY-us2';     $listid   =  'MYLISTID';     $endpoint   = 'http://us2.api.mailchimp.com/1.3/?output=php';          $request   = array(       'apikey' => $apikey,       'id' => $listid,       'email_address' => strtolower( $comment->comment_author_email ),       'double_optin' => true,       'merge_vars' => array(         ' <merge tag for name> ' => $comment->comment_author,         'OPTIN_IP' => $comment->comment_author_IP,       )     );     $result = wp_remote_post(       $endpoint.'&method=listSubscribe',        array( 'body' => json_encode($request) )      );     /////////////////////////////////////     ///////MailChimp  Ended////////////////////     ///////////////////////////////////                    }       }     }     add_action('comment_approved_','ymc_subscription_add',10,1);     add_action('comment_post', 'ymc_subscription_add', 60,1);      Also this code added to _comments.php_ file of theme (below `</form>`) :               <input style="width: auto;" type="checkbox" name="mailchimp_subscribe"   id="mailchimp_subscribe"/>     <label for="mailchimp_subscribe">     Subscribe     </label>     </p>      But when i trying to send a comment, i'm getting this error :               Warning: Missing argument 2 for ymc_subscription_add() in /home/content/blabla/themes/bueno/functions.php on line 36          Warning: Cannot modify header information - headers already sent by (output started at /home/content/blabla/themes/bueno/functions.php:36) in /home/blabla/html/wp-comments-post.php on line 95          Warning: Cannot modify header information - headers already sent by (output started at /home/blabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-comments-post.php on line 96          Warning: Cannot modify header information - headers already sent by (output started at /home/blabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-comments-post.php on line 97          Warning: Cannot modify header information - headers already sent by (output started at /home/contentblabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-includes/pluggable.php on line 897


Display future posts in archive

I'm using the following code to display an archive of posts.               <?php     // Get years that have posts     $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );          // For each year, do the following     foreach ( $years as $year ) {              // Get all posts for the year         $posts_this_year = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND post_status = 'future' AND YEAR(post_date) = '" . $year->year . "' ORDER BY post_date DESC" );                  foreach ( $posts_this_year as $post ) {                 // echoing miscellaneous stuff             }     }     ?>      There it says `post_status = 'publish'`. How can I add future posts to my archive? I tried adding `AND post_status = 'future'` to both `$wpdb->get_results` entries but it doesn't work.


Phantom 302 status code when sending a POST requests on pages

I really hope I've got a simple issue in front of me here, as it's sort of driving me up a wall. Short story: submitting a simple form on the front end of the site results in a `302 Found` redirect, totally stripping the `$_POST` data in the process. Scenario:   * Create a page in the admin called **Edit**   * Create a custom template file (ie, `my-edit-template.php`) and apply it to **Edit** `my-edit-template.php:`               <?php     /**      * Template Name: My Edit Template      */          if ($_POST['action']) {     var_dump($_POST);     }           get_header(); ?>          <form action="" method="post">         <input name="my-ornery-field" value="">         <input type="submit" value="submit">         <input type="hidden" id="action" name="action" value="update-profile">     </form>          <?php get_footer(); ?>      Now, when I submit the form, I get two requests to the same page, first, the `POST`, with the form data intact, and second, a `GET` (status code `200`), obviously stripped of the `$_POST` global, or anything useful to me. I'm sure this is a total oversight, but I'm at a loss; utterly confused. I've tried:   * All plugins disabled   * Flushing rewrites back to basic defaults   * `POST`ing via Javascript/`XHR` Help? _I'm sorry if the details are sparse, I'm sort of in class right now, but I'll follow-up with anything else relevant, later._


Tags are automatically converted if they match post names. Stop It!

Recently I noticed that if I had post tags that are the same as a page name, wordpress is updating the tag to the page title rather than the slug entered. So in this case if I give wordpress the tag `'adventure-training'` it is updated to `'Adventure Training'` similar to the name of a page on the site. How do I stop that from happening. Any ideas? Marvellous


Categories Going to different Blog Pages?

I've searched for this but can't find a clear answer. I'd like to have my main blog page display posts with certain categories and then have another blog page that shows different categories. How would I do this? Thank yoU! Matt


getting the post_id from the post_meta

I need to find out the post_id of a post_meta record where the custom key is 'XYZ' and the is 'ABC'? Is there an API for that? Or do I need to run a regular select SQL with wpdb class?


class="parent" for wp_list_pages?

             <?php wp_list_pages('exclude=&title_li='); ?>

      creates the following output...

Page 1

Page with Subpages

Page with another subpage

subsubpage

Page 3

Page 4

      All pages with children have a `ul class="children"` applied. Is it possible to create any function (or any other way) to append a classname to all pages THAT HAVE CHILDREN? In my example above only the "Page with Subpages" and it's first child-page "Page with another subpage" should have a `li.parent` applied. Is that possible on the serverside? I'm able to do it with javascript, however I wonder if there is a better and cleaner way to do it serverside? thank you


Echo Custom Taxonomy Field Values Outside the Loop

I have a custom taxonomy called 'game'; posts have a taxonomy value, i.e. Halo, which then has seven different fields; game_name, game_genre etc. I'm trying to echo the meta data for a given post's custom taxonomy albeit without much luck. The small piece of PHP that I tried to use to echo the metadata for the field game_name (designed to be run in a PHP widget) doesn't appear to work. It uses a custom hook created by the plugin Simple Term Meta               <?php     global $term;     echo get_term_meta($term->ID, 'game_name', true);     ?>      Any help in sorting this out would be appreciated, I didn't realise it'd be this complicated.


How do i 'deactivate' a plugin only on a certain page template?

I have a plugin which is great but it's kind of aggressive, and it changes a lot more than it should (but there are no settings to fix this). I have a custom page template that calls wp_head('less') ... header-less.php, and i have an equivalent for footer-less.php. I basically want, in this custom header-less.php to DE-REGISTER the plugin immediately after it gets registered. note that i dont want to DeACTIVATE the plugin, because i really need the functionality on the other page templates, only on this certain template do I want to basically 'destroy' the plugin or deactivate it somehow


How do I make header.php use different css for different pages?

I register styles in `function.php` with               function my_scripts() {         wp_deregister_style( 'header' );         wp_register_style( 'header', get_template_directory_uri() . '/css/header.css' );         wp_enqueue_style( 'header' );     }     add_action( 'wp_enqueue_scripts', 'my_style_sheets' );      I'd like to use different header style sheet for the same header.php file used on another page. How do I do that? In general, how do I use styles differentiated by template instead of using a global setting like the one above?


Wordpress automatically adding <!-- --> html tag around PHP code

I was managing a site, taking over from a previous administrator. With his last breath, he changed something on the site, precisely on the login section: http://www.spiritualresponse.com/login/ I don't know if intentionally or not, but the login form has vanished. This is an ASAP task to fix it, so what I can gather, the PHP code, that calls on the sidebarlogin plugin, gets auto commented. This has not happened previously and I have no clue what is causing it. Where I input the code, it is without the "" tags, but when it renders, the php gets commented out. I did not find any solution on google since searching for "auto commenting/ comment" detailed problems gives very different problems/solutions in the category of wordpress. All help would be appreciated, I hope this is some kind of "switch this and everything will be alright" problems :) ----EDIT1----- My bad in asking the question badly. This "system" or configuration worked previously, I have the exec-php plugin installed and it is working. Something got changed and now it is NOT working :(


Is it possible to isolate and use Wordpress functions outside of wordpress

I'm seeing a lot of jobs on elance and vWorker for converting html to wordpress? what's the general process for doiing this? hunting and pecking through the codex? what happens when you get to some javascript or php? how long should a job like this take?


Custom post types not imported properly

I've registered a custom post type:               function create_gallery_post_type() {       register_post_type( 'sim_gallery',         array(           'labels' => array(             'name' => __( 'Sim Gallery' )           ),           'public' => true,           'has_archive' => true,           'menu_position' => 10,           'description' => "Post for displaying gallery"         )       );     }      Now I'm trying to import the content from my staging server to my dev server.   During the import process, I get the feedback that it failed to import all my custom post. So clicking 'Sim Gallery' in the left navigation panel, shows zero posts. But if I look at the database, wp_posts, I can actually see the posts.   If I try to create a post with a name that is already registered, I get `somename-2` where `-2` indicates that a post by the same name is already registered. So my question is: 1) Why does the wp import function say that it failed to import my cistom posts?   2) Why are my custo mpost not shown in the post listing in the backend?


BackupBuddy, for backups, backups in general etc, any good?

So long story short, i was told by a new job that they want me to migrate 2 WP sites to other hosting id assume. now, im a so-so WP noob....i googled around so that when i go into work, i atLEAST have some notion of what im doing lol, and then i came across "backupbuddy" lets call it (BB) for now. so long story short, to test, i installed BB in my local wp install(WAMP), did the deed, and then took the files to my local WP install on my mac(MAMP) and i swear, in less than 5 minutes, i was done, it took it ALL and....yeah, done. When i tested on the mac WP, AFAIK, everything went through from plug ins to pages/posts/comments...even custom themed stuff i was working on etc..everything... and so...you know "If its too good to be true it usually is" and that whole shtick. i just want to make sure im ok b4 i do anything bad and break the site or something. my question is, Is this reliable? can i use this and be done with it or is there anything im going to need to know in general? anything i need to look out for etc... any thoughts/ tips/ advice / links etc ill gladly appreciate. Thanks in advanced.


Add text to metabox input text field from Thickbox

I have a custom post type with a metabox text input area that I want to have a shortcode inserted into from a thickbox when a link is clicked on from the modal window. Using the code below right now it just closes the modal window when the insert button is clicked. Please tell me where I am going wrong. I have the thick box opening fine. The page that is rendered has the link as this:               echo 'id.'">Insert	';      I have the jQuery call as:               jQuery('.insertdownload').click(function(){          var did = jQuery(this).attr('id');          did=did.replace('download-', '');          if (jQuery('#format').val()>0) {          jQuery('#my_new_field').val('[download id="' + did + '" format="' +           jQuery('#format').val() + '"]');          } else {          jQuery('#my_new_field').val('[download id="' + did + '"]');          }          window.parent.tb_remove();     });      I also have my metabox text field as:               <input type="text" size="25" name="myplugin_new_field" id="my_new_field">      This was the original code but I didn't want it to go to the editor window, I want it to go to my input field.               jQuery('.insertdownload').click(function(){     var win = window.dialogArguments || opener || parent || top;     var did = jQuery(this).attr('id');     did=did.replace('download-', '');     if (jQuery('#format').val()>0) win.send_to_editor('[download id="' + did + '" format="' + jQuery('#format').val() + '"]');     else win.send_to_editor('[download id="' + did + '"]');     });


Filters on the_content with plugins, pages and shortcode

I am using a plugin to add tweet, likes... This plugin add filters to `the_content()` to display this social buttons on a blog page (list of posts). I coded a shortcode which does a custom SQL query which displays posts. I even added `apply_filters( 'the_content', get_the_content() )` for these filters to be applied on `get_the_content()`. I added the shortcode on a page. The only one problem is that the buttons "like", "tweet" are not "linked" to the different posts but to the page. For instance, on one post, i have 2 likes and 10 tweets in a normal way and they are displayed on this page with a count of 0. I believe this buttons are in fact linked to the page and not to the posts. I tried with adding other plugins like voting, it is the same: the vote on the posts are not displayed.. I just want this buttons to be displayed like in a normal post loop. Is it a way to add this filters on `the_content()` in the shortcode loop and not in the `the_content` in the page. The blog list works well, votes and buttons are correctly displayed. I want the same behavior on a page with a shortcode displaying posts, is it possible? Thank you for your answers!


How to display comments list by order when clicking on newest or oldest link?

0 down vote favorite I have a wordpress single post where I have comment system - Live Site And I have two links one is: 1. newest 2. oldest The thing I want is when I will click on newest it will display the comments list in newest order and if I click on oldest it will display the comments list from oldest to newest. Any simple solution is fine (though I prefer using ajax but no need for ajax right now). GET and POST method will be fine. Any clue? Thanks in adavance


Features Posts / Featured list WP Slider plugins?

For some reason I can't find any working / recent Wordpress plugins that have the featured content / list that are on the right of slider window. **EG:** ![enter image description here](http://i.stack.imgur.com/2nHjM.jpg) Does anyone know where I can find any to use?


Use Featured Image of Post as Header Image

I have a blog on wordpress.com in which I make use of the Twenty Ten theme. For each Post I can set a Featured image. On Wordpress.com that image is then displayed in the header above the menu. I'd like to gain the same for a Wordpress.org setup. How can I do this?


Add a panel to edit post

I would like create a plug in that adds a panel of options to edit post page like the one added by All in One Seo but i cant find any good tutorial of any information about what is the correct action of filter tu use. Could you point me in the right direction? snippet?


wp_logout Not Logging Me Out

Here is what I'm doing:               wp_logout();     var_dump(is_user_logged_in());      var_dump returns:               bool(true)      Why is wp_logout() not logging me out?


Is it possible to give the user the chance to select between two single template files to use in a post?

Basically, I want to allow the user to select which template files he or she wants to use in a post: **single-asc.php** :               <?php $custom_posts = new WP_Query(); ?>                 <?php $custom_posts->query('post_type=bbp_topic&order=ASC'); ?>                 <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                 <?php endwhile; ?>      **single-desc.php** :                       <?php $custom_posts = new WP_Query(); ?>             <?php $custom_posts->query('post_type=bbp_topic&order=DESC'); ?>             <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
                     <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
             <?php endwhile; ?>      In this example, the user can choose (maybe by clicking a link) to see a post with the `single-asc.php` template file or `single-desc.php` template file. (the ASC and DESC example is just for reference, these two templates will have different code) Any suggestions to accomplish this?


Moving a blog from a subdomain to a folder

I'm going to move my blog from http://blog.wordfruit.com to http://wordfruit.com/blog the main Wordfruit site is in PHP and the blog is WordPress. I know I can make the change at wp-admin/options-general.php ...I want to make sure I don't create problems when I make that change...   1. Do I not need to create any folders etc on the domain? Will they just create themselves when I make the change?   2. Can I redirect the old urls to the new urls from within the WordPress account?   3. Are there any other things I need to account for in making this change? Cheers, Richard


Display post number not post ID number

I am wanting to display the number order of a post. I tried using`<?php the_ID(); ?>` but this just displays the post ID and doesn't seem to do go in sequential order due to post revisions and whatnot. Is there a way to to display if the post is #2 or #3 or #4 and so on? Thanks!


How do I display posts by day?

<?php $my_query = new WP_Query("cat=1&day=''&posts_per_page=-1"); ?>     <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>      I'm trying to display all posts from a single day on my homepage, restricted by category. The code above is what I'm using, but I've tried a bunch of variations on listing the current day and can't seem to get it to display posts only from the current day. I'm sure I'm missing something completely obvious, but how do I get this working to restrict posts by date? Although getting the homepage figured out is my first challenge, I also want to have my individual day archives set up in a similar way.


How to add tinymce to normal textareas (in wordpress admin)?

I have custom post type called coupon and custom taxanomy stores. At this page `edit-tags.php?taxonomy=stores&post_type=coupon` meaning while adding and editing stores I have a field called `Description`. I want to add tinymce to that. I can write like this: `<span style="color: red;">This is description</span>` but my client can't. So he want a wysiwyg editor there. Any idea how can I do this?


Line break no working on theme

I am working on an e-commerce site and the line breaks wont work, neither using the return button nor using `<br />` . I have been looking around but haven't found a solution that works. I would need to let the user simply push the return button and have a line break as he won't be experienced. Any help would be much appreciated, thanks in advance.


500 internal server error with wordpress

I always get 500 internal server error when I try to access my wordpress website, but if I put a php.ini (memory-limit:60MB) file in the WP-ADMIN folder, then I can access the site fine., but phpmyadmin doesn't work anymore with the following error:                Fatal error: session_start() [function.session-start]:         Failed to initialize storage module: files (path: ) in  /libraries/session.inc.php on line 83      I have another wordpress site with the same server configuration (LNMP), and it doesn't have this problem. Anyone know why I need that php.ini in the WP-ADMIN or why it is causing 500 error. Thank you. The wordpress install that have this problem is running the latest version 3.9.1.


What's the Best Way to Edit WordPress Files?

I have just started hosting a blog using WordPress. Now, I want to start editing php files to customize (I am a programmer). What are my various options? Should I use FTP, download files and edit locally? Or, should I login to server and edit? thanks


Audio link assembled in custom post type using ECPT shortcode does not render player on front end

I'm trying to get an audio player to display correctly in a WP custom post type, using a value from one of the meta fields and assembling the audio URL as follows:               //output the audio link using ecpt_vnc_username     function demo_audio_link () {              echo 'http://download.virtualnewscenter.com/demos/' .         do_shortcode('[ecpt_field id="anchor_username"]') . '.mp3';     }     add_action( 'genesis_entry_header', 'demo_audio_link', 11 );      for anchor_username=aspector, the post renders the URL literally (http://download.virtualnewscenter.com/demos/aspector.mp3) rather than as an audio player. Page source looks like this:
Alan Spector
http://download.virtualnewscenter.com/demos/aspector.mp3
      I've tried various incantations of print, printf and echo, including the audio shortcode in what is echo'd ([audio src="http://download.virtualnewscenter.com/demos/aspector.mp3"], single vs. double quotes, and hard-coding the audio player as               <audio class="wp-audio-shortcode" preload="none" style="width: 100%; visibility: hidden;" controls="controls"><source type="audio/mpeg" src="http://download.virtualnewscenter.com/demos/aspector.mp3"/></audio>
      All of them end up with the literal outputting to the page, not being handled by the WP parsing to either a link or an audio player. What am I missing?


Editing the Default Links like "Site Admin" in the Sidebar Meta Section?

After creating a new WordPress site, how can I edit the default links like _"Site Admin"_ found in the sidebar _"meta"_ section?


WPML : how to determine manually the language in which a given page is displayed

Somewhere in my code I need to know what is the current language and display a certain custom field or another one based on this knowledge. How can I know this information ?


Defining multiple categories for showing latest posts

I have a function that lets me display the latest posts on my website, however i want to function to show posts of multiple categories at not just one specific category. Check the code below and what i'm saying may start to make sense.               function latestposts()   {         $args = array( 'posts_per_page' => 4, 'cat' => '4', '5', '6', '7');                           $last_5_posts_query = new WP_Query( $args );         while($last_5_posts_query->have_posts()) :              $last_5_posts_query->the_post();             $link = get_permalink();             $title = get_the_title();                                             $content .= '
';             $content .= '
'              . get_the_post_thumbnail( null, "home-post-thumbnail")              . '
';             $content .= '
'.$title.'
';             $content .= '
' .get_the_excerpt(). '
';             $content .= '
';         endwhile;          return $content;      I made an attempt of making it show multiple categories with the below code, however it only shows items populating category 4. How do i make it display the posts from multiple categories? I thought the code below would work, but alas, does not.               $args = array( 'posts_per_page' => 4, 'cat' => '4', '5', '6', '7');


What add_rewrite_tag()'s RegEx matches against?

I'm trying to figure out wether I can specify the position of the string to match (i.e. immediately after the domain) to reduce the chances of matching something else, but I don't even know what the RegEx in add_rewrite_tag() matches against. Does it match against a full url including domain? or Does it match against everything after the domain? Thanks.


Searching Only Blog Posts From a WordPress Site's Main Posts Page?

On my CMS-style setup, I have the standard search box which searches everything. However, on my blog page, I would like to also have another search box which searches just the blog... is this possible, and how would I go about it? **EDIT** I used this code within a text widget which goes on my blog page:               <form  id='searchform' method='get'>     <input style='margin-top:5px;' type='text' name='s' id='s' placeholder='Search (blog only)'>     <input type='hidden' name='post_type' value='post' />     </form>      This has the advantage that the results page is styled like the blog, and not the standard search page. (though I don't know how to indicate that the page is showing search results.. how to show this?)


Registered but Anonymous comments

Is there a way / set of plugins that could enable discussion where each commenter is 'authenticated' with the site (via openid/fb/twitter/etc) but the commenter can still use a anonymous/fake name? Basically we want to avoid people using other peoples email addresses and masquerading as them (in a university situation, its not difficult to work out someone else's email...)


getting a post id from a custom type post

changed a wordpress to use custom type posts instead of pages. I'm Trying to update a plugin to work with this change. currently I'm stuck with just getting the right id from the post here's the relevant code:               add_action ('update_postmeta', 'wp_paypal_meta_change',1,4);          function wp_paypal_meta_change($meta_id,$post_id,$meta_key, $meta_value){     /*      handles cases of product metadata changes or added.  calls the needed functions:      get_pp_button or thumb_resize      and stores their products in hidden paypal variables     */         $pid = $post_id;         //echo($pid);         if ($meta_key == 'image'){         $themetaimage = get_post_meta($pid,'image',TRUE);         $urlp = get_page_link($pid);                   $themetathumb = thumb_resize($themetaimage,148,140,$urlp);//update the image thumb          update_post_meta($pid,'_thumb',$themetathumb);//and store it in the variable              } else if ($meta_key == 'shipping' || $meta_key == 'cost' || $meta_key == 'bookname'){         $themetacost = get_post_meta($post_id,'cost',true);         $themetaname = get_post_meta($post_id,'bookname',true);         $themetashipping = get_post_meta($post_id,'shipping',true);             if (!$themetashipping) {                         $themetashipping=($themetacost*0.1);//if no shipping - logic for calculating shipping                     }      This works fine! with pages, but fails miserably with custom type posts Actually I would be glad to just being able to see to different vars. How can I debug something without seeing it?


Permalink for regular posts "/blog/"

I'm trying to figure out how to accomplish the following: `http://www.mydomain/blog/my-blog-post/` I'm using the `/%postname%/` for my permalink structure, but this eliminates the "/blog/" from all posts that are technically blog only. Is there a way to ensure that "/blog/" is within the URL structure for regular Posts? * * * In addition, is there a way to REMOVE the post type slug from the URL for a Custom Post Type?


Get name and email of current unregistered user, who has recently submitted name and email in comment form?

From within a WordPress plugin, is there any way to get the name and email of the current user, when s/he is not logged in, but has recently submitted a comment, and specified name and email in the comment reply form? Or is the name & email only available during the HTTP request in which [the comment posted by the user] is being processed? (When the the user is _not_ logged in, the `WP_User` returned by `wp_get_current_user()` contains no info on the user's email or name, I've noticed when debugging.) (Background: I'm writing a comment rating plugin, and I'd like to highlight the user's ratings, even if s/he isn't a registered user. As mentioned in the comments below, perhaps some cookie will be needed in any case. I'm still interested in knowing the answer to this question however, perhaps I could reuse some existing functionality or something)


Navigation menu with children shown only for current page

I've been playing around with Wordpress' menu functionality (wp_nav_menu and wp_list_pages) to build a menu for my site. It's coming along, but I'm still having some trouble getting the behaviour I'd like. What I'd like is something like the sidebar menu on this website (not WP): http://www.fairfood.org/facts/sustainability-agenda/ When you click on a subpage that has children, the menu displays those children: http://www.fairfood.org/facts/production-chains/ I currently have this code:                           <?php // sidebar menu             if ($post->post_parent) {                 $ancestors=get_post_ancestors($post->ID);                 $root=count($ancestors)-1;                 $parent = $ancestors[$root];             } else {                 $parent = $post->ID;             }                  $children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0");                  if ($children) { ?>             <ul id="subnav">             <?php echo $children; ?>             </ul>             <?php } ?>      This works, but this shows the children that all the subpages have, not just the children of the current page. An example of what I mean: http://test.fairfood.org/facts/ Any have any idea to make this work?


"Preview Changes" button doesn't show changes for previously published posts/pages

When go in and make some changes to an article and click the "Preview Changes" button (without having first saved anything), another window/tab opens, but the article shown is the last saved version. That is, it's not showing any new changes I made. Anyone else run into this, or am I not understanding the functionality correctly? * * * **UPDATE:** Some specifics. Please note the URLs throughout. It is a Subdomain Network install using the Domain Mapping plugin and a "pretty" permalink structure.   * Network primary domain: example.com   * Secondary site: site1.example.com   * Mapped primary domain for site1.example.com: www.another-example.com   * Domain mapping settings have both "Remote Login" and "Redirect administration pages to site's original domain" _checked_. (See this forum post for explanation.) Logged in as an Editor user, I go edit a page with a slug of "tester" (http://site1.example.com/wp-admin/post.php?post=1834&action=edit) I make some changes to the content _without_ clicking "Update." Instead, I click "Preview Changes." A new window opens with the following URL redirects:   * site1.example.com/wp-admin/post.php   * site1.example.com/tester/?preview=true&preview_id=1834&preview_nonce=c5e51962c0   * www.another-example.com/tester/?preview=true&preview_id=1834&preview_nonce=c5e51962c0 This ends in a message saying, "You do not have permission to preview drafts." This is annoying as the remote login redirects have not taken place. As a work around I discovered that if I first preview at least one "draft" status post, all the remote login redirects take place. If I then go back to edit the "tester" page (http://site1.example.com/wp- admin/post.php?post=1834&action=edit) and click "Preview Changes," I again end up at http://www.another- example.com/tester/?preview=true&preview_id=1834&preview_nonce=c5e51962c0. However, it doesn't display any of the pending changes. Instead it shows the last saved version of the page. Any ideas? Thank you.


WPMU function get_blog_details, last_updated/registered and formatting time and date string

Within my multisite installation I can get the registered and last updated time strings for a sub blog through get_blog_details and the blog ID:               echo get_blog_details($blog_ID)->registered      Ok, how do I format the resulting time string:               2011-09-28 00:20:34      Thanks


wp_set_object terms won't remove all terms

I am trying to figure out why wp_set_object terms will update the terms in a given taxonomy but when I set the $terms param to NULL it keeps one of the terms - the one with the lowest ID. I've altered a plugin for frontend editing of posts - WP User FrontEnd. Here's my wp_set_object_terms code coming from a set of check boxes in a form:               if( !empty($_POST['wpuf_tax_TAXONOMY']) ):       $cat_ids = $_POST['wpuf_tax_TAXONOMY'];       $cat_ids = array_map('intval', $cat_ids);       $cat_ids = array_unique( $cat_ids );       wp_set_object_terms( $post_id, $cat_ids, 'TAXONOMY' );     else:       wp_set_object_terms( $post_id, NULL, 'TAXONOMY' );     endif;      Not sure what to do about this or why it won't delete the terms when none are selected in the form. Any help is appreciated. EDIT--------------------------------------------------------------- I have noticed that wp_set_object_terms does add and remove terms as expected. But I need to refresh the page after the form update to see the changes. I tried a wp_redirect on successful submission but got a "headers already sent" error. Is there a way to reload the page with out having to refresh the page after the from updates? Hope that made sense.


No three-columns template in TwentyEleven?

I am just jumping into the TwentyEleven bandwagon, and I am a little puzzled by the apparent absence of a 3-columns template file... It is advertised in the theme description though. Am I missing something?


How do I pass arguments to dashboard widget callback functions?

I'm struggling to use the $callback_args parameter of wp_add_dashboard_widget successfully. The following code keeps displaying string(0)"" when dumping $args:               add_action( 'wp_dashboard_setup', 'sample_widget_setup' );          function sample_widget_setup() {              wp_add_dashboard_widget(             'sample_dashboard_widget',             'Sample Widget',             'sample_dashboard_widget_callback',             null,             'sample_string'         );     }          function sample_dashboard_widget_callback($args) {         var_dump($args);     }      How can I pass a variable to sample_dashboard_widget_callback?


Query for specific taxonomy that executes a particular loop depending on volume of posts?

Is it possible to create a special wp query that looks to see how many posts exist in a specific taxonomy, or taxonomy term, and executes a particular loop depending on the volume of posts? My idea behind this is -   **Id like to be able to show particular CPT content in a different styled format depending on how many of those posts exist**. For example:   _Lets say the **taxonomy "product categories"** only contains about **2 posts** listed with **child terms** that exist in that taxonomy **rather then something like 20**...   Well what Id like to do is list those products in a larger style via CSS instead of having to default on the more consolidated styling for when their are a larger volume of products._ Can this be done, and if so how?


Send and Embed Vine (in WP Post) on Facebook

I've written a bunch of functions in my theme's functions.php so that I can use a shortcode to post Vine videos, e.g `[vine id="hx9LlrZxdqV"]`. My functions will then grab the raw .mp4 URL and output it as a video on my post page. The client also wants me to be add Facebook integration so that when the Post is published with the Vine shortcode in, the video is simultaneously sent to Facebook where it's embedded as video so the users can play it on Facebook as well, much like Vinescope do. As an addition, I will also need to add the Facebook comments to to WP post and possibly also get the number of Likes and Shares for each video/Facebook post. Here are my functions to output the Vine on Wordpress:               function vine($id) { // gets the raw .mp4 url from the vine id         $vine = file_get_contents("http://vine.co/v/{$id}");         preg_match('/property="twitter:player:stream" content="(.*?)"/', $vine, $matches);         return ($matches[1]) ? $matches[1] : false;     }     function vineDesc($id) {         $vine = file_get_contents("http://vine.co/v/{$id}");         preg_match('~<\s*meta\s+property="(twitter:description)"\s+content="([^"]*)~i', $vine, $matches);         return ($matches[2]) ? $matches[2] : false;     }     function vineAuthor($id) {         $vine = file_get_contents("http://vine.co/v/{$id}");         preg_match('~<\s*meta\s+property="(twitter:title)"\s+content="([^"]*)~i', $vine, $matches);         $authorName = preg_replace('/\'s post on Vine/', '', $matches[2]);         return ($authorName) ? $authorName : false;     }               function embedVine($atts) {              extract(shortcode_atts(array(             "id" => '',         ), $atts));              $vine_id = $id;              $videourl = vine($vine_id); // assigns the raw .mp4 url from vine() function above to variable         $vineDesc = vineDesc($vine_id);         $vineAuthor = vineAuthor($vine_id);              $output = "";              $output .= "
<video class='vine-embed'><source src=". $videourl ." type='video/mp4'></video>

" . $vineDesc . " by " . $vineAuthor . " →

" . postShareBtn() . "
";              return $output;          } add_shortcode("vine", "embedVine");      I'm open to using Plugins but if possible I'd like to avoid using them as much as possible. EDIT: Also, if the embedding the Vine on Facebook can't be done, it would be ok if it would just post a link to the Vine for the user to click on, and then get the comments and possibly likes/shares too to display on the Wordpress page. Thanks! Thanks for any help :)


Order Custom Posts by Several Fields

I have a page that lists out the members of our band, as a custom post type. I am trying to order the members by several custom fields, field by category, or "section, then by their class, and then by name. All these are entered as custom fields. Any idea on how to do this? Here is the page: http://www.uconnband.org/members


Why should I keep my personal wordpress separate from my "professional" one?

(this might be better suited as a community wiki, can one of the mods edit it please?) **Info** : I have one main blog, where I discuss IT stuff like programming, android, Java etc which compensates my day job nicely (Java developer). I want to start blogging about other, non related interests (such as karate, fitness, languages etc). **Question** : Would it be best suited to setup a second installation of wordpress for these, or should I just keep one installation and separate using categories? What are the pros/cons of doing this?


uploading photos

I am very new to word press, and I have been trying to upload photos to my posts, and each time I do, it says there is an error "has failed to upload due to an error Failed to write file to disk." I used to be able to do this, and now it will not let me.


Toolbox theme using printif statement - help needed understanding code block

I want to make edits to the following so that I can display the author and date but without those being links to searches 'by date' and 'by author'. The site I'm building will only have one author and I want to lock down the searches users can do. Code as follows:                       <?php                 printf( __( 'Posted on <time class="entry-date" datetime="%2$s" pubdate>%3$s</time>  by  %6$s', 'toolbox' ),                     get_permalink(),                     get_the_date( 'c' ),                     get_the_date(),                     get_author_posts_url( get_the_author_meta( 'ID' ) ),                     sprintf( esc_attr__( 'View all posts by %s', 'toolbox' ), get_the_author() ),                     get_the_author()                 );             ?>      Any help understanding what how this code block is working would be great. Thanks all.


Check with jQuery value of checkbox from custom admin panel

i am trying to create my first admin panel for my theme. I have a simple checkbox which i think is working. Where is this information stored? Is this information stored in the database? How can i then check it's value? I would like to read this value with jQuery. Is it possible? This is my array for the checkbox:               array( "name" => "Followers Count: ",     "desc" => "Select if you want to display the number of followers of your blog (at the bottom of your widget bar)",     "id" => $shortname."_followers",     "type" => "checkbox",     "std" => ""),      Please let me know any other information you may need. Thank you for your help! =)


Show meta box only when post is being published first time

I'm creating a WordPress plugin where it is required to show the meta box only when a post is being published for the first time. The only way I can think of is to show the metabox iff there is no $_GET['post'] parameter set(it represents the post ID), but then meta box will not be visible for the posts which are in draft. Is there any way to determine if the post has been published before?


Compatibility with RTL installations

I want develop a plugin that add boxes and menus in WordPress backed. What I have to keep in mind to make it **compatible with WordPress RTL** installations? Any idea or suggestion will be appreciated. Thanks


Trouble Removing Plugin

I'm editing this site http://www.millermusicproductions.com/ currently and I am trying to get rid of the login in the upper-right corner. I go to plugins and deactivate a plugin called "Login with AJAX", then I refresh the page and only the page's header displays. Anyone know what I'm doing wrong?


Having trouble with custom post type / meta box

I've been working on a custom post type meta-box implementation that allows me to change the post_date to match the value in my "date" meta-box. The function works perfectly except when I try to add a new custom post, I receive a blank page! I know it's this function because if I remove it, I can create a new post no problem. Here is my function:               function cfc_reset_postdate( $data ) {      // If it is our form has not been submitted, so we dont want to do anything     if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;          if($data['post_type'] == 'scripture-memory') {         $date = $_POST['cfc_date'];         $date = DateTime::createFromFormat('D - M j, Y', $date);         $date = $date->format('Y-m-d');              $data['post_date'] = $date;         return $data;     }     }          add_filter( 'wp_insert_post_data', 'cfc_reset_postdate', '99', 1);      Any ideas on why I'm receiving a blank page when trying to create a new post? EDIT: I've changed my code to reflect your ideas: function cfc_reset_postdate( $data ) {               //if($data['post_type'] == 'scripture-memory') {         if($_POST['cfc_date'] != '') {             $date = $_POST['cfc_date'];             $date = DateTime::createFromFormat('D - M j, Y', $date);             $date = $date->format('Y-m-d');                  $data['post_date'] = $date;             return $data;         }          //}      } add_filter( 'wp_insert_post_data', 'cfc_reset_postdate', '99', 1); Only problem is when I create a new post, it only allows me to create a draft, and then it comes up with a blank page that says "Are you sure you want to do that?" I'm going to work on this more, it looks like we're making progress. Thanks everybody for your help!


Are links allowed in the Upgrade Notice section of a plugin's readme.txt file?

I'm working on an updated version of an existing plugin. In the readme.txt file, I'll be adding an entry to the "Upgrade Notice" section, which will show up in users' Plugins admin page when the new version gets released. I see from the official readme.txt format that this field is limited to 300 characters. My question is, are links allowed in this field? I would like to link to a forum post about the new version. I realize I could put a URL in the field in any case, but I was wondering if I could put a link in the field using the Markdown syntax and make the link clickable on the users' admin screen.


$paged always 0 on plugin's custom page

I'm making a plugin that loads a specific template depending on a certain query var being passed, in effect creating a page for the plugin on the front end, as outlined in this post: Create a page without adding a page in the Database - the first answer by Brian Fegter So if I head to mysite.com/foobar I can use my custom template. However, if I hook a function up to wp_head and print out the paged query_var, it always returns 0, regardless of the value in the url (mysite.com/foobar/page/2, or example). Any thoughts as to why this is happening? Is there a better way for my plugin to create a new page on the front end? Thanks in advance.


Wordpress admin section appears broken

My word press admin area looks like the image linked below. I have tried reinstalling word press using the option in the `Updates` panel. But I cannot get it to revert. Has anybody had a similar problem and knows the solution? My guess is that it's css but shouldn't have reinstalling WP sorted that out? Need more rep to include this image in the post


Why are my WordPress store items showing up in duplicates?

I recently became an admin of a WordPress site, for the purpose of setting up a store. I have little WordPress knowledge, so I will try to be as specific as I can. I am using the WP e-commerce plug in, version 3.7.6.7 Someone else was originally in charge of the store and added some items, since then we updated the word press version and I added many more items. The store page was set to display all items and it displayed them alphabetically..... While I was adding it items, editing stock #s, etc, at some point some items started showing up twice in the store. I also noticed it wasn't showing up all of the items, while duplicating others. In the admin section, all of my items are listed correctly - just on the products-page there are duplicates. Not knowing any better solution, I duplicated several items and deleted the originals and everything was showing up only once. Having grown the store in # of items, I went into appearance settings and changed it to be listed 10 items per page. Then selected "drag and drop" to arrange the items. When I went to arrange them, only a partial list of items came up, so I changed it back to alpha. When I did this, all of the items that were on my partial list from the drag and drop section were now duplicated in the store. So in two completely different scenarios, I've somehow ended up with items showing up twice. How can I fix this and prevent it from happening again when I make changes?


Adding Metabox Value Using the content filter

I am able to show repeater metabox on index and single post .Now I want to show this using               add_filter( 'the_content', 'theme_slug_filter_the_content' );      My code to get meta value               <?php     $data = get_post_meta($post->ID,"repeatable_fields",true);     echo '
';     if (count($data) > 0){         foreach((array)$data as $p ){             if (isset($p['name']) || isset($p['select'])|| isset($p['url'])){                 echo '
Number: '.$p['name'].' Description: '.$p['select'].' Price: '.$p['url'].'
';             }         }     }     echo '
';     ?>      I guess My code will be               function theme_slug_filter_the_content( $content ) {     $custom_content = 'YOUR CONTENT GOES HERE';     $custom_content .= $content;     return $custom_content;     }     add_filter( 'the_content', 'theme_slug_filter_the_content' );


Plugin a specific cache functionality?

I have written a plugin that puts a (google) favicon in front of each link in my blog. Really simple. Just uses a simple preg_replace_callback on hrefs:               $changed_html_reference = preg_replace_callback(self::HTML_REF_REGEX,         array($this,'AddExtraHtmlToOneHref'), $strHtmlBodyText);      with a               add_filter('the_content', array($this,'ReplaceAll'), 9);      for the replacement and a default call to the google site for the icon (snip out of class) :               const GOOGLE_ICON_URL = 'http://www.google.com/s2/favicons?domain=';     function HttpDownloadFeed()     {      $parsed_url = parse_url($this->url);        $data_r = wp_remote_get(self::GOOGLE_ICON_URL . $parsed_url['host']);      $data = $data_r['body'];      return $data;     }      I now have taken the approach of making my own cache class which stores the icons in directories like e.g. /cache/com/facebook/www/f.png. But I am now thinking about the location of that class. For easiness i placed the cache in the wp-content directory. The following questions I have:   * could i plugin an existing cache / cache plugin to do the caching for me?   * what is the best location for my own cache thing? should i put it under /wp-content/cache or /plugins/myplugin/mycache or even /themes/mytheme/cache ? or is there even a better approach to this? (I am using the com/facebook/www approach because i also store session date of stumbleupon, delicious etc...in there and i only want to call these pages/feeds once incl. the request for a google favicon) (and since i need to display the icon and not all browser support inline displaying of icons embedded in html i need to write them to a directory available to the client).


How to disable controls in theme customizer?

Edit: I have rewritten the question in hopes I will get a reply from someone who knows the theme customizer. I am trying to figure out how to disable setting controls in the Wordpress theme customizer page. An example is:   1. A section in the theme customizer contains a checkbox that is used to hide or show text in a hero container. When it is checked it will hide the text. The checkbox label says "Hide hero text".   2. Within the same section there is a textbox for the user to enter the text they want for the hero container. The label says "hero text". I am trying to figure out how to disable the textbox(2.) when the checkbox(1.) is checked. By disabling I am referring to making the textbox inactive so nothing can be input into it. Can anyone explain how this can be done? Information on the theme customizer is very scarce at this time. I would greatly appreciate it.


Redirecting to page not found mulitiste

when you make a new site from the network admin panel, and then go to the site dashboard it comes up with a "page not found" message. I am working in localhost/mulitsite/ is the redirect url is correct               RewriteEngine On     RewriteBase /wpmu/     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) C:\xampp\htdocs\wpmu\$2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ C:\xampp\htdocs\wpmu\$2 [L]     RewriteRule . index.php [L]


Strategies to implement selective loading of plugins

I'm trying to figure out some kind of mechanism to load plugins on demand, depending on the page url, to improve performance. My primary concern is that I have some admin-ajax.php calls that are recurring while the user is active on the page. I tried profiling these calls, and discovered that the majority of plugins loaded for the ajax call were unnecessary. While I could use `is_admin()` to identify an ajax call, I wish to leave WordPress and plugin code intact. Plus, `is_admin()` does not differentiate between an ajax call and admin panel. I've been looking into the plugin loading procedure. I only saw `'muplugins_loaded'`, `'plugins_loaded'` actions, no filters to tap into the loading process. I checked `wp_get_active_and_valid_plugins` and it appears the only way to change plugin loading is to `update_option('active_plugins')` explicitly, which is not a viable option. Other things are hard coded. (I'd like to mention that this plugin http://wordpress.org/extend/plugins/selective-loading/ use the `update_option` method, which in my opinion is only suitable in a non-ajax environment, or otherwise the option change wouldn't be atomic.) I'm wondering if there was still some way to implement selective plugin loading?


Rewrite Slug for CPT Archive Pages to Plural Name of Slug

I have a custom post type with the rewritten slug of `plugin` creating the url structure of http://site.com/plugin/plugin-slug/. Which makes the CPT Archive as http://site.com/plugin/ I'd like to rewrite it, without using a page and a custom page template, to use http://site.com/plugins/ (Which is the `labels=>Name` in the CPT). while keeping the slug for the single posts as `/plugin/` This would also need to support things like `/plugins/page/21 - which it currently does.


How can users sort multiple pages?

I'm using the following code to display a list of properties on multiple pages. I would like to give users the option of sorting the results by custom fields (perhaps city, or property name, or price). I've tried add_query_arg without success. Does anyone have any suggestions? I would truly appreciate a code example as I'm fairly new to PHP. Thank you so much.                               <?php                     $wp_query = new WP_Query(array(                         'meta_query' => array(                             'relation' => 'AND',                             array(                                 'key' => 'listing_status',                                 'value' => array('Active', 'In Contract'),                             ),                             array(                                 'key' => 'listing_type',                                 'value' => 'For Lease'                             )                         ),                              'paged' => $paged,                         'orderby' => 'title',                         'order' => 'ASC'                          ));                          $paged = (get_query_var('paged')) ? get_query_var('paged') : -1;                          ?>