Taxonomies, restrict editing and creation of terms?

Can I stop my client from adding terms to a certain taxonomy? So that I set up a fixed amount of terms, and that´s what they get to choose from. Can I remove the menu item for certain taxonomies in the backend? Let´s say I have created two taxonomies, and I want the user to be able to access one of them and the other should be hidden and only show up as options in the editing of posts/pages.


insert element inside wp menu list item

I am not sure if it is clear from the title what I want to achieve here so let me try to clarify this. I wanna make use of Wordpress's menu system and need to adjust it to my needs, which means that I need it to go **from here** :

item1

item2
     etc.
      **to here** :

1(dynamic-content)
item1

2(dynamic-content)
item2
     etc.
      What would be the best way to achieve this?? Just need some quick directions to go there and do it myself without losing too much time finding appropriate solution. Is it the `wp_nav_menu()` or `wp_get_nav_menu_items()` that I should be researching? Short sample would be appreciated as well if it's not too much to ask. And another thing.. I would appreciate tip on how to generate number inside that inserted `div` that represents menu item's order apperance: 1,2,3,etc. Is there a way to pick up this from Wordpress's core? Thank you so much. Any help appreciated.


Can you set up a wordpress (multi-site) network to work across multiple hosting accounts?

I would like to manage multiple sites running as part of a single wordpress network, but I don't want to personally host each of the individual sites. I don't mind if my database holds all the tables for each site, but I don't want to be the sole host for all the files, etc for each site. Is there any way to do this?


.sub-menu or .children?

I'm developing a theme using a test installation (using InstantWP), but when I upload it to a staging site, for some reason the nav menu looks inflated. After looking at the source, it turned out to be that for some reason my test install uses the class `.sub-menu` while the staging install uses `.children`. Both installs are fresh installs of 3.3.1 with the exact same plugins installed. Why would there be such a discrepancy between the two installs?


How to determine if theres a next page

I am new to wordpress development, just trying to convert my HTML into a WordPress theme, I started with Chris Coyer's blank theme.

<?php next_posts_link('« Older Entries') ?>

<?php previous_posts_link('Newer Entries »') ?>

      How can I output the div only if there is a `next_posts_link()`. I need this as I will be using `<ul>` for my pagination. If I don't do that, I will get an empty bullet


Not able to change wp_title using add_filter

I have a custom page where I try to change the page title.   The function executes, but the title is not changed. This is the code I'm using:                 add_filter('wp_title', set_page_title($brand));            function set_page_title($brand) {          $title = 'Designer '.$brand['name'].' - '.get_bloginfo('name');         //Here I can echo the result and see that it's actually triggered         return $title;         }       So why is this not working? Am I using add_filter wrong?


create new user role for reader

is there a way to add a new user role? I need two kind of readers:   1. can read all private posts   2. can read just private posts from a specific category. Subscriber as described here could be fair enough to satisfy the first kind of reader. Then what I need is to define something less than subscriber, once I can test if a user has this new role for me it's ok.


Get all sticky posts from one user through user ID

So I need to get number of sticky posts each user have and compare it to one variable. I managed to do this, but I am wondering is this the right way to do it.                //Retrive all sticky posts ID             $sticks = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name = 'sticky_posts'");             $stickies = unserialize( $sticks[0]->option_value ); //array with the IDs of sticky posts             // print_r($stickies);             // Get user id from sticky post ID             $i = 0;             foreach ($stickies as $sticki) {                 $post_meta = get_post($sticki);     if($post_meta->post_author == $current_user->ID && $post_meta->post_status != 'trash' && strtotime($post_meta->post_date) > strtotime('-30 days') ) { $i++; }             }      And $i is number of sticky posts for that user. So what I am doing is looping through all sticky posts, getting post meta for each sticky post and through post meta getting post author to compare it with current user id.


Get current custom user taxonomy

I’m using the plugin User Groups which lets me group users with categories. The plugin is working essentially the same as using the manual method (custom user taxonomies) described by Justin Tadlock here. On author.php I want to list the taxonomies the currently viewed user belongs to, and each list item should link to the taxonomy term page. I use the following code to get current user ID and retrieve custom field values from the profile page:               <?php // Get current author          $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));          ?>      And I use the following code to list the custom user taxonomies:               <?php // List custom user taxonomies          wp_list_categories('taxonomy=user-group');          ?>      "taxonomy=user-group" is fetching all of the terms created within the plugin. Here’s a way to get current post taxonomies, but I’m looking to change it to custom user taxonomies. Is there a way for me to change wp_list_categories() to only display the taxonomies I want? Should I be looking for another approach?


Query users by capability - uninstall/deactivate callback

## The situation Running on MU, I'm writing an open source/publically and freely available plugin. As I used `add_screen_option()` to allow users to easily setup the admin page to their likings, I'm left with a bunch of user meta data. Now the page itself is restricted to users with the `manage_options` capability, so only those have got this meta entry when they adjusted the `per page` value for a list table. > ![The "per page" Screen Option](http://i.stack.imgur.com/Bxdzx.png) ## The task To allow the plugin to leave a clean state in case some chooses to remove the plugin, I added a deactivation and an uninstall hook callback that should loop through user data and remove the meta entries. Now I could simply loop through all users, check their meta value and so on, but this would hardly fail on sites with lots of users and end in a time out (remember, Meta tables are `JOIN`ed). ## The idea (so far) To make it short, here's what I thought: The MU install has a `user` and a `usermeta` table. And from what I can see, there're not really capabilities saved, but role names - WordPress makes no difference between roles and capabilities here. Fun as it is, it seems that there're different things I have to consider: **User can be …**   * superadmin   * registered on multiple sites   * registered on multiple sites with different roles   * registered on multiple sites with the same role, but role has different capabilities on different sites   * ...? The problem starts with those different possibilities and goes further, when you look at ho the capabilities are saved in a Network/MU setup:               {$wpdb->prefix}capabilities      Or               {$wpdb->prefix}{get_current_blog_id()}_capabilities      So for what would one query?               $query_args = array(     );     $query = new WP_User_Query( $query_args );     $users = $query->results;     if ( empty( $users ) )         return;          var_dump( $users );      ### EDIT Just a first attempt to query for role names with a specific capability:                   $roles = new WP_Roles();         $roles = wp_list_pluck( $roles->role_objects, 'capabilities' );         $results = array();         foreach ( $roles as $role => $caps )         {             array_key_exists( 'manage_options', $caps )                 AND $results[] = $role;         }         var_dump( $results );              # Even if it's smarter then above loop, it won't work and          # throw an error in core files.         $roles = array_filter( wp_list_pluck( $roles, 'manage_options' ) );


Showing home button in a specified menu

I try to add the home button in a specified WordPress menu (I have 2) and it's not working at all. This is my code:               <?php wp_nav_menu(array('theme_location' => 'primary', 'show_home' => $args['show_home'] = true)); ?>      Calling the 'global $args;' didn't work. What I'm doing wrong? Thanks in advance.


Identify the page being shown while in The Loop

In my loop, I'm trying to set it so that certain text is displayed on certain pages, if there are no posts to display. I thought this would be simple, using `is_post()`, but it seems that this function does not work when you are in The Loop. Does any body know how I can identify the page that is currently being shown, whilst in The Loop? The below code is from `loop.php` \- it's how I have the code structured, as the content is not important in this instance. However, for those interested, here is my full `page.php` and `loop.php` code - http://pastebin.com/hDjR6C7A.               <?php if(have_posts()) : while(have_posts()) : the_post(); ?>                  <!-- Do stuff here -->              <?php endwhile; ?>          <?php else : ?>              <?php if(is_page(162)) : // Careers ?>                  <!-- Do stuff here -->              <?php if(is_page(716)) : // Partnerships ?>                  <!-- Do stuff here -->              <?php elseif(is_search()) : ?>                  <!-- Do stuff here -->              <?php endif; ?>          <?php endif; ?>


How can I get the title attribute from get_the_post_thumbnail()?

In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself. Is there a simple way to do this? Where should I be looking? Thanks, John.


Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT

Wondering if someone could tell me why sub pages (child pages) no longer work (eg: www.mysite.com/type/childpage). I have a page called "Type" (working fine), and I wish to have Child Pages of "Type" (404 errors)- as you can see I also like to have the "type" rewrite slug in front of my custom post types/taxonomies. I tried the method from this link to no avail: http://wordpress.stackexchange.com/questions/4127/custom-taxonomy-and-pages- rewrite-slug-conflict-gives-404               add_action( 'init', 'create_zombie_type' );          function create_zombie_type() {     register_post_type('zombies',      array(       'description' => 'Zombie custom post type',     'show_ui' => true,     'menu_position' => 5,     'menu_icon' => get_stylesheet_directory_uri() . '/images/zombies.png',     'exclude_from_search' => false,     'labels' => array(         'name' => 'Zombies',         'singular_name' => 'Zombie',         'add_new' => 'Add New Zombie',         'add_new_item' => 'Add New Zombie',         'edit' => 'Edit Zombies',         'edit_item' => 'Edit Zombie',         'new_item' => 'New Zombie',         'view' => 'View Zombie',         'view_item' => 'View Zombie',         'search_items' => 'Search Zombies',         'not_found' => 'No zombies found',         'not_found_in_trash' => 'No zombies found in Trash',         'parent' => 'Parent Zombie',     ),     'hierarchical' => false,     'supports' => array('title','editor','excerpt', 'trackbacks','custom-fields',     'comments','revisions','thumbnail','author','page-attributes'),     'public' => true,     'rewrite' => array('slug' => 'type/%freshness%', 'with_front' => false),     'taxonomies' => array('freshness')     )      );     }                         add_action( 'init', 'create_zombie_taxonomies' );          function create_zombie_taxonomies() {     register_taxonomy(      'freshness',      'zombies',     array(      'labels' => array(         'name' => 'Freshness',         'singular_name' => 'Freshness',         'search_items' =>  'Search Freshness',         'popular_items' => 'Popular Freshness',         'all_items' => 'All Freshness',         'parent_item' => 'Parent Freshness',         'parent_item_colon' => 'Parent Freshness:',         'edit_item' => 'Edit Freshness',          'update_item' => 'Update Freshness',         'add_new_item' => 'Add New Freshness',         'new_item_name' => 'New Freshness Name'     ),      'hierarchical' => true,      'public' => true,     'show_ui' => true,     'query_var' => 'freshness',     'show_tagcloud' => true,     'rewrite' => array( 'slug' => 'type', 'with_front' => false )      )         );          }                    function filter_post_type_link($link, $post)     {     if ($post->post_type != 'zombies')     return $link;          if ($cats = get_the_terms($post->ID, 'freshness'))     $link = str_replace('%freshness%', array_pop($cats)->slug, $link);     return $link;     }          add_filter('post_type_link', 'filter_post_type_link', 10, 2);


What causes wp_schedule_single_event to fire off?

This isn't as simple of a question as you may think. Basically I have a C# program that is hitting the worpdress site and the wp_schedule doesn't seem to fire off. If I go to the site with my firefox browser then it seems to fire- off. Soooo what's the difference here? What exactly causes the cron to fire? Is it the HTTP GET? Or is there some script or function inside the page that is loaded by browsers?


Wordpress Custom Query: Combining Two Functions

I'm a bit new to php and am having some trouble combining the functionality of two custom queries in Wordpress in order to (1) get pagination to work properly, and (2) sort my posts according to a voting plugin. **(1) The following is a custom query, which is working with pagination, but does not sort my posts according to votes (set in a voting plugin).**               $total = "     SELECT wposts.*     FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta     WHERE wposts.ID         =   wpostmeta.post_id     AND wposts.post_status  =   'publish'     AND wposts.post_type IN     ('youtube', 'vimeo')     GROUP BY wposts.ID     ";          $totalposts = $wpdb->get_results($total, OBJECT);     $ppp = intval(get_query_var('posts_per_page'));     $wp_query->found_posts = count($totalposts);     $wp_query->max_num_pages = ceil($wp_query->found_posts / $ppp);      $on_page = intval(get_query_var('paged'));            if($on_page == 0){ $on_page = 1; }       $offset = ($on_page-1) * $ppp;          $wp_query->request = "     SELECT wposts.*     FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta     WHERE wposts.ID         =   wpostmeta.post_id     AND wposts.post_status  =   'publish'     AND wposts.post_type IN     ('youtube', 'vimeo')     GROUP BY wposts.ID     LIMIT $ppp OFFSET $offset     ";          $pageposts = $wpdb->get_results($wp_query->request, OBJECT);      **(2) The following is another custom query. When this query is combined with the function in #3, it does sort my posts according to votes. However it does not work with pagination.**               $enddate = date('Y-m-d');     $increment_date = strtotime("+1 day", strtotime( $enddate ));     $enddate = date("Y-m-d", $increment_date);          $increment_date = strtotime("-1 month", strtotime( $enddate ));     $startdate = date("Y-m-d", $increment_date);          $query = "     SELECT wposts.*     FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta     WHERE wposts.ID         = wpostmeta.post_id     AND wposts.post_status  = 'publish'     AND wposts.post_type IN ('youtube', 'vimeo')     AND post_date           >= '$startdate'     AND post_date           <= '$enddate'     GROUP BY wposts.ID     ";      **(3) And the function for sort according to votes is...**               function ShowPostByVotes($query) {          global $wpdb, $voteiu_databasetable;     $upperlimit = get_option('voteiu_limit');     if ($upperlimit == '') { $upperlimit = 100; } $lowerlimit = 0;          $votesarray = array();              $pageposts = $wpdb->get_results($query, OBJECT);          $query_limited = $query." LIMIT ".$lowerlimit.", ".$upperlimit;          $posttablecontents = mysql_query( $query_limited );          while ($row = mysql_fetch_array($posttablecontents)) {         $post_id = $row['ID'];         $vote_array = GetVotes($post_id, "array");         array_push($votesarray, array(GetVotes($post_id)));     }     array_multisort($votesarray, SORT_DESC, $pageposts);     $output = $pageposts;     return $output;     }      My difficulty is that I can't seem to create a query/function that both sorts my posts by votes, and also works with pagination...I apologize I know it's a bit of a big question, but I've been struggling with this for a few days with no luck and can't seem to get anywhere.


ensure user can only be logged in on one computer at a time?

how can i make sure a user can only be logged in on one computer at a time? I want to make a wordpress site that could potentially have paid accounts for content in the future. Is there anything built into wordpress that prevents a user from being logged in more than once?


Wordpress Custom post type won't save properly

Note: I first asked this question on stackoverflow but didn't get an answer. I created a plugin with a new custom post type, it works locally as it should but on one of my websites, which happens to be a multisite, it won't properly save when I add a new custom post item. When I first try to publish it, it will still save as a draft and the meta box values are not being saved while I am using the save_post hook. Also I am always redirected to /wp-admin/post.php when I save instead of staying on the edit page like it normally does. This is the custom post type code:               public function download_post_type() {         $labels = array(             'name' => _x('Downloads', 'post type general name'),             'singular_name' => _x('Downloads', 'post type singular name'),             'add_new' => _x('Add New', 'download'),             'add_new_item' => __('Add New Download'),             'edit_item' => __('Edit Download'),             'new_item' => __('New Download'),             'all_items' => __('All Downloads'),             'view_item' => __('View Download'),             'search_items' => __('Search Downloads'),             'not_found' =>  __('No downloads found'),             'not_found_in_trash' => __('No downloads found in Trash'),              'parent_item_colon' => '',             'menu_name' => __('Downloads')         );         $args = array(             'labels' => $labels,             'hierarchical' => false,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,              'show_in_menu' => true,              'query_var' => true,             'rewrite' => true,             'menu_icon' => 'http://cdn1.iconfinder.com/data/icons/CrystalClear/16x16/apps/ark2.png',               'taxonomies' => array( 'category' ),              'capability_type' => 'post',             'has_archive' => true,              'hierarchical' => true,             'menu_position' => 5,             'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions' )              );          register_post_type('downloads', $args);     }


"NOT ONLY IN" taxonomy query operator?

I have multiple users adding content to restricted categories (using RoleScoper) in my WordPress setup that don't show up on the homepage (custom template with `query_posts()`). I'm looking for a way to "promote" the submitted content to the homepage by adding it to another category. My loop code looks like this:               <?php     query_posts($query_string . '&cat=-37');     if (have_posts()):         while (have_posts()): the_post(); ?>      This will exclude all posts in category 37. However, even if I add the post to a different category it still gets excluded. Is there a way to exclude a post if it belongs to just that one category?


Create a frontpage.php and static page template

I am a little confused. **Reading settings :** 1) Front page -> Home -> `Frontpage.php` 2) Posts page -> News -> `pages_news.php` [this is custom page template :Pages Custom news ] From Pages: 3) Pages -> News -> Edit -> Template -> Pages Custom news My `frontpage.php` works but my custom page template `pages_news.php` from news didn't work. specifically, i customize the template with other settings or remove all and didn't work. It displays all the content. Also, I want to publish the first 6 posts (Without the sticky post) to `frontpage.php` and the others posts or articles to `pages_news.php`


jQuery accordion plugin won't work once used in WP

I'm tryin to use this accordion script in my WP: http://www.armagost.com/zaccordion/ Problem is that on a standalone html/php file it works well but once pasted in my header.php file there's no way to make it work. I tried also including it with `<?php require_once("example.php") ?>` but no success. You can see my header.php file here: http://pastebin.com/SrkmWxp1 Thanks for your help.


Post Editor not working on WordPress 3.5.1

Recently i have updated my wp site to the latest version and since then post editor not working, **What i have tried:**   * Disabled all plugins.   * Installed "Use Google Libraries".   * Disable all plugins except "Use Google Libraries".   * Re-install WordPress from the update panel. **Followed some solutions on WordPress support:** Adding this line in wp-config.php Solution #1:               define('SCRIPT_DEBUG', true);      Solution #2:               define('CONCATENATE_SCRIPTS', false );      i have tried all of the above methods and none of them worked for me. please help me with this issue because i can't able to update my website :(


Query posts without a specific ID

How would we query posts as long as the post does not equal the ID 2047? Here is the current query.               <?php      $args1 = array(         'post_type' => 'options',         'tag_slug__and' => array( $triplevel, $divingtrip, 'accommodation' ),         'posts_per_page' => -1,         'offset' => 1,     );      query_posts( $args1 ); while (have_posts()) : the_post();     ?>      I tried this...               query_posts( $args1 . 'p!=2047' );      ..to no effect. Any ideas? Marvellous


How do I exclude a custom taxonomy from the post loop

Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer. I know it can be done via a WPDB query, but that just seems like massive rope to jump for something that should be fairly simple.


Search within a page

I am wanting to have a search box within wordpress pages to search and display results just from the content on that current page. Anyone have any suggestions on how to achieve this?


Need help with my template

I have this site here http://spillersmart.dk where it currently shows 3 videos in a row. I want it to show 5 videos instead, but can't figure out where in the code to change that. I've looked into the css-file, but without any luck :-( Thanks in advance


Change multi-site installation from sub-domains to sub-directories

I've searched everywhere but I don't seem to find a solution for this. I have a WP installation that is using sub-domains and doesn't have yet any other sites besides the main site. What I want to do, without reinstalling from fresh, is enabling sub-directories. I tried changing in the wp-config `define( 'SUBDOMAIN_INSTALL', true );` to `define( 'SUBDOMAIN_INSTALL', false );` and it allowed to create a site in a sub-directory but when viewing the site I can see only the HTML (no CSS) and I can't access the administration area of the site. I'm guessing there's something else that needs to be done so the paths work. Any ideas?


Preserve Search engine index while shifting to new Domain

We are in process to migrate old old domain to new domain using wordpress. this migration is happening on the same server and IP (need to confirm but still 99% sure). I have already asked same question few time back on pro- webmaster preserve-search-engine-index-while-shifting-to-new-domain. Since the database is same, all we did is export the data from old database to new database changed the link and now everything is perfect. i know about that we can set 301 redirect in the .htacces file but not sure how to do this, and since there are so many links in the old domain. i am not sure how best we can handle this redirect. Do we need to create a mapping for each old URL to new URL? and where we should put these mapping in the Old domain? any help in this regard will be much helpful.If i need to provide more information, please let me know i will put any other required information in post. Thanks in advance


How can I insert an image map into a Wordpress blog post?

I'm trying to insert a custom image map into a blog post, so that clicking on different parts of an image at the top of the post will lead to anchors in other parts of the post. I have generated the image map code correctly, and tested it in a separate non-wordpress plain HTML page, where it worked fine. Whenever I insert the HTML (using the code view, not the WYSIWYG editor view), it gets erased as soon as I save the post. However, I checked and it looks like `<map>` and `<area>` are both permitted tags on Wordpres.com. This blog is not hosted by Wordpress.com (it's actually a site on the WPMU instane hosted right here on Stack Exchange), but I would assume that by default, the downloaded version of Wordpress would allow at _least_ the same tags as the Wordpress.com hosted blogs. Is there a setting which a network super-admin has to change to allow these tags, or am I inserting them incorrectly? If the tags are allowed, what might cause them to be outright removed?


Wordpress remote file storage

I am in pretty much the same position as the author of this post. I understand my post is something of a duplicate but the link is a few years old and I wonder if the situation has changed any? I have a client who runs (and loves) a WordPress website and uses Dropbox for sharing files with their clients (typically digital copies of contracts & machine manuals). They don't like using Dropbox as its not integrated with the website and isn't branded. I had hoped there was a Dropbox API that allowed for user/group based access to folders but there doesn't seem to be. Are there any plugins/services out there that fit the bill or is the only option still to use Amazon S3?


Enhance Media Manager for Gallery

I would like to enhance the Media Editor, after WordPress 3.5, on the gallery view.   I want to add a new select field on the right side and send the selected values to the gallery shortcode. ![enter image description here](http://i.stack.imgur.com/brx7x.png) I think, the function `wp.media.gallery` in `wp-includes/js/media-editor.js` is the default function to insert the gallery shortcode. I want to add a new parameter and the values of the parameter come from the select field inside the Media Manager. I have played with different sources, especially from this question, but Backbone is very new for me and I don't understand how it works. I have also played with the hook `print_media_templates`, but no result on the Media view. What hooks should I use?


Using database meta_values to calculate new post order using pre_get_posts or a 'request' hook

**UPDATE: I have worked out my implementation of the selected answer at the bottom of this post.** I'm implementing a sorting algorithm based on Reddit's hotness algorithm, in addition to a time-decay (like Hacker News hotness algorithm). The code I am currently satisfied with is a result of trial and errors in some Excel sheets and whatnot. Here's the working code in PHP:               <?php get_header();     $timenow = time() - 1211380200; // this is my custom Epoch time, it translates to when my first WP post was made ?>          <?php     if ( have_posts() ) : while ( have_posts() ) : the_post();           $hearts = get_post_meta($post->ID, '_tjnz_hearts', true);     $plays      = get_post_meta($post->ID, '_tjnz_deals_plays', true);     $downloads  = get_post_meta($post->ID, '_tjnz_deals_downloads', true);     $ups        = get_post_meta($post->ID, '_tjnz_temperature_upvotes', true);     $downs      = get_post_meta($post->ID, '_tjnz_temperature_downvotes', true);     $date       = get_post_time('U', true); // fetches the GMT postdate of post in Unix format          $score = ( ( $hearts * 2 ) + $plays + $downloads + $ups ) - $downs;     $order = log( max( abs( $score ), 1 ), 6 );     $seconds = $date - 1211380200;     if( $score > 0 ) { $sign = 1;   } elseif( $score < 0 ) { $sign = -1; } else { $sign = 0; }     $hotness = round( $order + ( ( $sign * $seconds ) / 336000 ), 7 );     $degrees = round( ( $order * ( $sign * 32 ) ) + ( ( -4 * ( $timenow - $seconds ) ) / 336000 ), 7 ); ?>
                 <?php the_title(); ?> <?php echo $post->ID; ?>
                 <?php echo 'hearts: ' . $hearts . '
';                 echo 'plays: ' .$plays . '
';                 echo 'dls: ' .$downloads . '
';                 echo 'up: ' .$ups . '
';                 echo 'down: ' .$downs . '
';                 echo 'date: ' .$date . '

';                 echo 'score: ' .$score . '
';                 echo 'order: ' .$order . '
';                 echo 'seconds: ' .$seconds . '
';                 echo 'timenow: ' .$timenow . '
';                 echo 'difference: ' .($timenow - $seconds) . '
';                 echo 'sign: ' .$sign . '

';                 echo 'hotness: ' .$hotness . '
';                 echo 'degrees: ' .$degrees; ?>

          <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>      **The problem** The problem with this PHP code is that the WordPress query was already made, so it just returns the posts in anti-chronological order.   * I want to sort posts by 'Hotness' score   * I don't want to use a new WP_Query object or query_posts() because that will stomp on the original query, which causes unnecessary Database interactions. The site is fairly busy and I'm hosting over a thousand posts now.   * I'm not sure how to utilize `pre_get_posts` or use the `request` hook. Yes, I have read the documentation but for me it's getting too advanced now. **The database structure** I am saving meta_values in table `wp_postmeta`, as you can see from my PHP code snippet. The actual Hotness score is calculated on-the-fly, and not saved into the database because that wouldn't be very efficient and most of all, not real time for users. **My actual question** I can't sort the query by `meta_value`, because the meta_values are only part of the equation. I want to use the **result** of the equation as sorting order. How do I change the main WordPress query to look at the meta_values, calculate each posts hotness, and return those posts from hottest to coldest? _**My implementation of the chosen answer_** In `functions.php` I have added the following two functions.               // add custom wp_postmeta when a new post is created     add_action( 'wp_insert_post', 'tjnz_prepare_postmeta' );     function tjnz_prepare_postmeta( $post_id ) {         if ( !wp_is_post_revision( $post_id ) ) {             $hotness = round( ( time() - 1211380200 ) / 336000, 7 );             add_post_meta( $post_id, '_tjnz_hearts', 0, true );             add_post_meta( $post_id, '_tjnz_plays', 0, true );             add_post_meta( $post_id, '_tjnz_downloads', 0, true );             add_post_meta( $post_id, '_tjnz_upvotes', 0.000, true );             add_post_meta( $post_id, '_tjnz_downvotes', 0.000, true );             add_post_meta( $post_id, '_tjnz_hotness', $hotness, true );         }     }          // build an array of Hotness stats for post     function tjnz_temperature( $tjnz_post_id, $tjnz_timenow ) {         $hearts     = get_post_meta($tjnz_post_id, '_tjnz_hearts', true);         $plays      = get_post_meta($tjnz_post_id, '_tjnz_plays', true);         $downloads  = get_post_meta($tjnz_post_id, '_tjnz_downloads', true);         $ups        = get_post_meta($tjnz_post_id, '_tjnz_upvotes', true);         $downs      = get_post_meta($tjnz_post_id, '_tjnz_downvotes', true);         $hotness    = get_post_meta($tjnz_post_id, '_tjnz_hotness', true);         $date       = get_post_time('U', true);         $score      = $hearts + $downloads + $ups - $downs;         $log        = log( max( abs( $score ), 1 ), 6 );         $seconds    = $date - 1211380200;         if( $score >= 0 ) {              $sign = 1;         } else {              $sign = -1;         }         $degrees    = round( ( $log * ( $sign * 32 ) ) + ( ( -9.6 * ( $tjnz_timenow - $seconds ) ) / 336000 ) + 10, 7 );         //      round to 7 digits    positive/negative    -2.4 degrees/day      realtime post age       +10 free degrees              return array(             'hearts'    => $hearts,             'plays'     => $plays,             'downloads' => $downloads,             'ups'       => $ups,             'downs'     => $downs,             'score'     => $score,             'hotness'   => $hotness,             'degrees'   => $degrees         );     }      `_tjnz_hotness` is now a meta_value for every published post, and will be updated every time a user upvotes, downvotes, downloads, or favorites (hearts) a post. The value of `_tjnz_hotness` is initially based on the publish time (GMT) of the post with a `score` of 0. The publish time is based on the Unix Epoch timestamp of the post, minus my personal Epoch (the date my blog launched). It really doesn't matter what that number is, it just makes the `_tjnz_hotness` value lower. A post published right after my blog launched will have a value close to 0. `_tjnz_degrees` is calculated on every page load. The page uses function `tjnz_temperature()` to calculate the `degrees` value at the time the page was loaded. It fetches all the meta info from the post, and uses it to calculate the current temperature of the post. The main difference between `hotness` and `degrees`, is that `hotness` is used for the actual sorting of the post. Increasing/decreasing this value basically offsets the post on a timeline, relative to other posts. The `degrees` value is based on this, but it takes the realtime age of a post into account. Essentially, what this means is that if a post's `hotness` doesn't change, the `degrees` value actually starts dropping (0.1 degree per hour, 2.4 per day). The setup of the `log` base 6 also makes it so that more and more upvotes are needed to keep the post 'hot'. Eventually there will be a point where it simply can't win from newer posts anymore. With my formula, it takes about 5-7 days for a post to become inevitably 'cold'. On my custom page, I list the posts as follows (it's a debug output, no actual post content is shown yet).               <?php     /*     Template Name: Hot     */     get_header();     $timenow = time() - 1211380200;      $hot_query = new WP_Query(         array(             'post_status' => 'publish',             'post_type' => 'post',             'meta_key' => '_tjnz_hotness',             'posts_per_page' => 30,             'orderby' => 'meta_value_num',             'order' => 'DESC'         )     );          if ( $hot_query->have_posts() ) : while ( $hot_query->have_posts() ) : $hot_query->the_post();          $tjnz_temperature = tjnz_temperature( $post->ID, $timenow );     ?>         <?php the_title(); ?> <?php echo $post->ID; ?>
         <?php echo 'hearts: ' . $tjnz_temperature['hearts'] . '
';         echo 'plays: ' . $tjnz_temperature['plays'] . '
';         echo 'dls: ' . $tjnz_temperature['downloads'] . '
';         echo 'up: ' . $tjnz_temperature['ups'] . '
';         echo 'down: ' . $tjnz_temperature['downs'] . '
';         echo 'score: ' . $tjnz_temperature['score'] . '
';         echo 'hotness: ' . $tjnz_temperature['hotness'] . '
';         echo 'degrees: ' . $tjnz_temperature['degrees']; ?>
          <?php endwhile; else : ?>
Oops, Post Not Found!
          <?php endif; get_footer(); ?>


Theme Options - localhost to new url

Im having this issue that happens to me each time i work on a website. On every project i start working locally and once im done i export my Database and search replace all localhost url's to the website destination url. than in cpanel i create a database user name and password. i modify wp-config. the website works fine all pages working just one thing wont work: Theme Options wont show my theme options and widgets wont show up and i have to redo this process from the beginning each time and redo all the settings. i have read a lot about it: http://codex.wordpress.org/Moving_WordPress but still don't know what am i doing wrong. same thing happens when i try to install a site on local host from a backup. is there a tutorial on how to do this right. Thanks in advance


WordPress Admin very slow

Hi my wordpress admin is acting really slow, is there some diagnostic plugin I can use (like Debug queries on the front end) to see which plugin is slowing down the dashboard?


One random post from multiple custom post types

I'm building a post grid on my front page and I'd like to show one random post per CPT. At the moment, CPT are queried out in a query array:               <?php     $c = 1; //init counter     $bpr = 3; //boxes per row        $wp_query = new WP_Query(array('showposts' => 9, 'orderby'=> 'rand', 'post_type' => array('productions',  'plays', 'movies', 'theatres', 'directors', 'artists', 'countries', 'events', 'grades')));     while( have_posts() ) : the_post(); ?>               <div class="post" id="post-<?php the_ID(); ?>">
<?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?>
        <a href="<?php the_permalink() ?>" rel="bookmark">           <?php if ( has_post_thumbnail() ) {              the_post_thumbnail('thumbnail');             } else { ?>             <img src="<?php bloginfo('template_directory'); ?>/img/fallback_image.jpg" alt="<?php the_title(); ?>" />           <?php } ?>
     <?php     if($c == $bpr) :     ?>

     <?php     $c = 0;     endif;     ?>     <?php             $c++;             endwhile;          ?>      So the problem with this array is that it starts to dublicate the CPT's when I query them, sometimes even it queries 4 random posts from CPT. One solution would be to create 9 different queries - one for each CPT, but this seems to be overkill for the front page. Is there a way to really only query 1 random post per CPT in a way that wouldn't affect the page loading time so much?


Wordpress is trimming leading 0s

I am inserting into the DB in the following manner:               // insert the info into the db          $wpdb->insert(              'wp_vkrwps_table',              array(                 'zip' => $zip                ),              array(                  '%d'                  )          ); // end insert      However, leading zeros keep getting trimmed. So if the input value is for example `00501`, I end up getting `501` in the DB table. Why is this?


How can i retrive a text from a custom field

I retrieve the date of an actor by selecting the date. `'data_nasterii'` is the name of the custom field.               <?php $data = get_field('data_nasterii'); echo date("d/m/Y", strtotime($data)); ?>      If i do not select anyting, I'd like to return: `N/A` for the actor birthday.   How can I integrate in this code? If there's a value:   Ex: Birthday :22/11/1978 If I don't select anything I want:   Birthday: N/A


Single page not working for custom post type

I created a custom post type with the following code:               add_action('init', 'create_trans_career');          function create_trans_career() {         //Arguments to create post type.         $args = array(             'labels' => array(                 'name' => __('Career', 'trans'),                 'singular_name' => __('Career', 'trans'),                 'add_new' => __('Add New', 'trans'),                 'add_new_item' => __('Add New Career Item', 'trans'),                 'edit' => __('Edit', 'trans'),                 'edit_item' => __('Edit Career Item', 'trans'),                 'new_item' => __('New Career', 'trans'),                 'view' => __('View', 'trans'),                 'view_item' => __('View Career', 'trans'),                 'search_items' => __('Search Career', 'trans'),                 'not_found' => __('No Career item found', 'trans'),                 'not_found_in_trash' => __('No Career item found in Trash', 'trans'),             ),             'public' => true,             'show_ui' => true,             'capability_type' => 'post',             'hierarchical' => true,             'has_archive' => true,             'menu_icon' => get_bloginfo('template_directory'). '/images/career-icon.png',             'supports' => array('title', 'editor', 'thumbnail'),             'rewrite' => array('slug' => 'career', 'with_front' => false),         );              //Register type and custom taxonomy for type.         register_post_type( 'career' , $args );     }      I also created a single page (single-career.php):               <?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>

                 <?php the_content('Read More...'); ?>                 <a href="<?php bloginfo('wpurl'); ?>/career" title="<?php _e('Back to jobs listings', 'trans'); ?>" class="back-to-jobs"><?php _e('Back to jobs listings', 'trans'); ?>                 <?php endwhile;  ?>      ..and a page template to list the posts:               $mypost = array( 'post_type' => 'career', 'posts_per_page' => 10, 'paged' => $pagedNum );                 $loop = new WP_Query( $mypost ); ?>                 <?php while ( $loop->have_posts() ) : $loop->the_post();?>                 <tr id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                     <?php the_title(); ?>	                     <?php echo $location; ?>	                     <?php echo $close_date; ?>	                     <a href="<?php the_permalink(); ?>" title="<?php _e('Details', 'trans'); ?>"><?php _e('> Details', 'trans'); ?>	                     <a data-title="<?php the_title(); ?>" data-location="<?php echo $location; ?>" href="#apply_<?php the_ID(); ?>" title="<?php _e('Apply Now', 'trans'); ?>" class="career-apply"><?php _e('Apply Now', 'trans'); ?>
                 <?php endwhile;  ?>      I created a page with jobs using the template above.. it's working I see all posts.. but when I open a single page I receive 404 error. Where is the problem?


hSite has no css on mobile

Our WP site got hacked and we've been working with our hosting to clean all malware etc. However, now the site appears on desktop fine, but on mobile it looks as though all the css is stripped. Here's the site: http://italiancottage.pleaseproof.com/


Creating a menu page in a Object Oriented developed plugin

I am trying for the first time to build a plugin for Wordpress following OOP way. I am having some problems while trying to create a submenu page using `add_users_page()` function. Here is a simple version of my code :               class MyPlugin  {         public function __construct()         {            add_action('admin_menu', array($this, 'create_menu'));         }              public static function create_menu()         {         add_users_page( 'My Plugin Menu', 'My Plugin Menu (Test)', 'list_users', 'mp_test_page', array($this, 'display_test_page'));         }              public static function display_test_page()         {         if ( !current_user_can( 'list_users' ) )  {         wp_die( __( 'You do not have sufficient permissions to access this page.' ) );                 }         echo '
Test page
';         echo '
The Problem : I cannot see that output in the corresponding submenu page
';         }     }     new MyPlugin();      The problem is that I cannot see the html output in the `display_test_page()` function... although the submenu page was indeed created in the Users general menu. Thank you in advance for your help,


What is the 'admin_action_' . $_REQUEST['action'] hook used for?

There's an action hook triggered in `admin.php` called `'admin_action_'.$_REQUEST['action']`. Unfortunately, it's a bit useless for plugins as it's triggered at the very end of admin.php, after everything's loaded on the page (even the footer). Does anyone know why it's there, why in that silly position and if anything is using it internally?


wp-admin blocking causing http error on uploads

I'm using this function to prevent users apart from admin from getting to the backend of wordpress. (Note, that addition to allow ajax requests too):               add_action( 'init', 'my_block_users' );          function my_block_users() {           $isAjax = (defined('DOING_AJAX') && true === DOING_AJAX) ? true : false;              if(!$isAjax) {                  if ( is_admin() && ! current_user_can( 'administrator' ) ) {                 wp_redirect( home_url() );                 exit;             }              }     }      Trouble is, it causes an http error when uploading images etc. Does anyone know a work around for this? Thanks!


menu using category and tags

I'd like to do (somehow) manual menus that would display all posts within certain category. Eg, I'd have sections "applications" and "games" so now i can do this: www.site.com/category/applications,games/ and get all from both categories I can do www.site/com/tags/android,iphone,ipad/ - which would give me all related, but from both categories. I'd like to keep categories and do something like www.site.com/category/applications&tags/android,iphone,ipad/ That would only display applications avoiding games. Is that possible without additional plugins and such stuff ? Tnx.


correct way to call javascript into hook function

function node_wp($post_ID) {         global $post;         $post_title = get_the_title( $post_ID );         $post_url = get_permalink( $post_ID );         $json = array(             'title_post' => $post_title,              'url' => $post_url         );         $data = json_encode($json);          $server_url = get_option('$node_server_url_op');         ?>         <script src="<?php echo $server_url; ?>"></script>         <script type="text/javascript">             var socket = io.connect('<?php echo $server_url; ?>');             socket.on('connect', function(){                 socket.emit('adduser');                 socket.emit('sendchat', '<?php echo $data; ?>');             });         </script>         <?php     }     add_action('publish_post', 'node_wp');      When running my script I get this:               Warning: Cannot modify header information - headers already sent      Can you tell me how to properly add Javascript?


Manually Remove and Change WordPress Page/Post Title

I have added custom metaboxes into the wp-admin page and post editors. There is a metabox with the ability to enter in a person's first name (ex. "John") and last name (ex. "Doe"). I want to set that particular post's/page's title to the combined values of those form entries (ex. "John Doe") without having to enter it in the top page/post title bar. This would, thus allow the post/page to behave like a contact card. Preferably, I would like this to work with permalinks too. _I must include any non-native and new code into the functions.php file of my child theme **only**._ For Reference: I am using the Genesis Framework. Any suggestions?


Change Default Image HTML

I am making a Wordpress theme and want to change the default image html. For example if you upload an image using Wordpress uploader it generates the following html for your images                                   I want to change it to something like this


Categories widget show empty?

Is there a way I can display all categories in the categories widget that comes with wordpress. I do not want to have to edit the core files and I want to stay away from rewriting the widget, but if need be I will. Is there anyway to hook into the widget just to get this functionality.


current_page_item is missing inside wp_nav_menu

I'm using the function `wp_nav_menu` like this:               <?php wp_nav_menu( array(                               'container' => false,                              'echo' => true,                              'before' => '',                              'after' => '',                              'link_before' => '',                              'link_after' => '',                              'depth' => 0,                              'walker' => new my_walker())                              ); ?>                    class my_walker extends Walker_Nav_Menu     {           function start_el(&$output, $item, $depth, $args)           {                global $wp_query;                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                     $class_names = $value = '';                     $classes = empty( $item->classes ) ? array() : (array) $item->classes;                     $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );                $class_names = ' class="'. esc_attr( $class_names ) . '"';                     $output .= $indent . '
ID . '"' . $value . '>';                     $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';                $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';                $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';                $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';                     $prepend = '
';                $append = '
';                $description  = ! empty( $item->description ) ? ''.esc_attr( $item->description ).'' : '';                     if($depth != 0)                {                    $description = $append = $prepend = "";                }                           $item_output = $args->before;                 $item_output .= '';                 $item_output .= '
'.$args->link_before .apply_filters( 'the_title', $item->title, $item->ID );                 $item_output .= $description.$args->link_after.'
';                 $item_output .= $prepend;                 $item_output .= $append;                 $item_output .= '';                 $item_output .= $args->after;                      $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);                 }     }      But in this menu the class `current_page_item` is missing. Is there something wrong in my code? How can I add this class?   Thanks!


How do you add custom taxonomy capabilities exactly?

I can't see to get it. The capabilities fail to appear when using plugins like "Capability Manager" or "Members" to view a list of available capabilities. This is the code I'm attempting to use:               add_action( 'init', 'register_taxonomy_spot_tag' );          function register_taxonomy_spot_tag() {              $labels = array(              'name' => _x( 'Spot Tags', 'spot tag' ),             'singular_name' => _x( 'Spot Tag', 'spot tag' ),             'search_items' => _x( 'Search Spot Tags', 'spot tag' ),             'popular_items' => _x( 'Popular Spot Tags', 'spot tag' ),             'all_items' => _x( 'All Spot Tags', 'spot tag' ),             'parent_item' => _x( 'Parent Spot Tag', 'spot tag' ),             'parent_item_colon' => _x( 'Parent Spot Tag:', 'spot tag' ),             'edit_item' => _x( 'Edit Spot Tag', 'spot tag' ),             'update_item' => _x( 'Update Spot Tag', 'spot tag' ),             'add_new_item' => _x( 'Add New Spot Tag', 'spot tag' ),             'new_item_name' => _x( 'New Spot Tag Name', 'spot tag' ),             'separate_items_with_commas' => _x( 'Separate spot tags with commas', 'spot tag' ),             'add_or_remove_items' => _x( 'Add or remove spot tags', 'spot tag' ),             'choose_from_most_used' => _x( 'Choose from the most used spot tags', 'spot tag' ),             'menu_name' => _x( 'Spot Tags', 'spot tag' ),         );              $args = array(              'labels' => $labels,             'public' => true,             'show_in_nav_menus' => true,             'show_ui' => true,             'show_tagcloud' => true,             'hierarchical' => false,                  'rewrite' => true,             'query_var' => true,             'capabilities' => array(                 'manage_terms' => 'manage_spot_tags',                 'edit_terms' => 'edit_spot_tags',                 'delete_terms' => 'delete_spot_tags',                 'assign_terms' => 'assign_spot_tags'             )         );              register_taxonomy( 'spot_tag', array('spot'), $args );     }      I generated the above code with this tool: http://themergency.com/generators/wordpress-custom-taxonomy/


Possible to disable autop temporarily?

If I disable autop entirely, I need to add `<p>` everywhere I want a paragraph. Is it possibe to disable autop temporarily? Like in a shortcode


Generate Navbar In WordPress

I am currently developing a custom theme. I need to generate menu with submenu. By default wordpress provides me result like below:

 Home

 About Us

Values

Vision & Mission

Quality

      I want the sub menu to come out from main ul. I need to exact result as below:

 Home

 About Us

Values

Vision & Mission

Quality

      And I tried using the below php class in wordpress but the result is failure               class menu_default_walker extends Walker_Nav_Menu     {              function start_lvl(&$output, $depth){             $output .= '

';         }              function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output){             $id_field = $this->db_fields['id'];             if ( is_object( $args[0] ) ) {                 $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );             }             return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );         }              function start_el(&$output, $item, $depth, $args) {             global $wp_query;             global $rb_submenus;                  $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $new_output = '';             $open_class = '';             $depth_class = ($args->has_children ? 'parent ' : '');                  $class_names = $value = '';             $classes = empty($item->classes) ? array() : (array) $item->classes;                  $current_indicators = array('current-menu-item','current-menu-parent','current_page_item','current_page_parent');                  $newClasses = array();             foreach($classes as $el)                 if(in_array($el,$current_indicators))                 array_push($newClasses,$el);                  $class_names = join(' ',apply_filters('nav_menu_css_class',array_filter($newClasses),$item));                  if(strpos($class_names, 'current-menu-parent') > 0 || strpos($class_names, 'current_page_parent') > 0) {                 $class_names = ' class="' . $depth_class . $open_class . 'opened"';             } else if($class_names != '') {                 $class_names = ' class="' . $depth_class . $open_class . 'selected"';             } else if($class_names == '') {                 $class_names = ' class="' . $depth_class . $open_class . 'menu-item"';             }                  if ( !get_post_meta( $item->object_id , '_members_only' , true ) || is_user_logged_in() ) {                 $output .= $indent . '
ID . '"' . $class_names . '>';             }                  $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';             if($item->object != 'portfolio_category' && $item->object != 'gallery_category')                 $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';             else                 $attributes .= ' href="#"';                  $portfolio_count;             $gallery_count;                  if($item->object == 'portfolio_category'){                 $terms = get_terms('portfolio_category', array('include' => $item->object_id));                 $portfolio_count = $terms[0]->count;                 $attributes .= ' data-category="true" data-filter="' . $terms[0]->slug .'"';             }                  if($item->object == 'gallery_category'){                 $terms = get_terms('gallery_category', array('include' => $item->object_id));                 $gallery_count = $terms[0]->count;                 $attributes .= ' data-category="true" data-filter="' . $terms[0]->slug .'"';             }                  if($item->attr_title == 'allportfolio' || $item->attr_title == 'allgallery'){                 $attributes .= ' data-all="true" data-filter="*"';             }                  $item_output = $args->before;             $item_output .= '
';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             $item_output .= ($item->object == 'category' ? ' ('. get_category($item->object_id)->count . ')' : '');             $item_output .= ($item->object == 'portfolio_category' ? ' ('. $portfolio_count . ')' : '');             $item_output .= ($item->object == 'gallery_category' ? ' ('. $gallery_count . ')' : '');             $item_output .= ($item->attr_title == 'allblog' ? ' ('. wp_count_posts()->publish . ')' : '');             $item_output .= ($item->attr_title == 'allportfolio' ? ' ('. wp_count_posts('portfolio')->publish . ')' : '');             $item_output .= ($item->attr_title == 'allgallery' ? ' ('. wp_count_posts('gallery')->publish . ')' : '');             $item_output .= '
';             $item_output .= $args->after;                  if ( !get_post_meta( $item->object_id, '_members_only' , true ) || is_user_logged_in() ) {                 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );             }                  $output .= $new_output;              }              function end_el(&$output, $item, $depth) {             if ( !get_post_meta( $item->object_id, '_members_only' , true ) || is_user_logged_in() ) {                 $output .= "
\n";             }         }              function end_lvl(&$output, $depth) {                  $output .= "

\n";              }          }


I want a part of the_content be under custom post types

On my homepage I have put some information on the page in wordpress. I show this content with `the_content();`. I also have 3 different custom post types that show under this content which is what I want. But now I need to have a part of the content that comes from the page in wordpress to be under these custom post types. I made a image to clear things ups. How do I do this without removing "THIS" from the homepage page in wordpress ![enter image description here](http://i.stack.imgur.com/fBiKQ.png)


WordPress wpautop/shortcode generating invalid markup

I notice that theres invalid markup in my shortcode. Its ok if I disable `wpautop` tho               function shortcode_banner($attrs, $content = '') {         echo ' --- ' . $content . ' --- ';         $html = '

' . do_shortcode($content) . '

';         die($html);     }      When autop is enabled I get (notice the closing `</p>` at the start?)               ---

The title
     xxx ... xxx ...     ---

The title
     xxx ... xxx ...

      When disabled I get                ---
The header
     xxx ... xxx ...      ---

The header
     xxx ... xxx ...

      **UPDATE** : I notice this happens only when I have a tag (e.g. `<h1>`) after my shortcode. Like:               [banner]
Test
      If I have               [banner]     xxx ...      it's ok, except Wordpress adds a `<br />`


Add a Class to Current Page WP_LINK_PAGES

I've noticed WordPress has some illogical differences between wp_link_pages and paginate_links. Specifically, WP_LINK_PAGES does not automatically add a class to the current page like paginate_links does. Anybody have a quick functions fix?


How to add a widget area between blog posts in Genesis Framework?

What's the code for adding a widget area between my blog posts? Specifically I want to put one widget area inbetween after the first 3 posts of my blog?


Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line:               echo $bannerimg       And this function in functions.php:               if ( is_page( '2533' ) ) {             // also tested with 'Apple'         $bannerimg = 'apple.jpg';          } elseif ( is_page( 'test' ) ) {             $bannerimg = 'test.jpg';          } elseif ( is_page( 'admissions' ) ) {          $bannerimg = 'admissions.jpg';          } else {          $bannerimg = 'home.jpg';     }        The point is the $bannerimg echoes "home.jpg" on every page, including Apple, test and admissions. I've even checked all the IDs using the_ID & $page->ID. Nothing. So I guess there's something wrong with the code above?


Show a list of recently viewed posts to a user

I have a lot of video posts on my site and I'm looking to show the user a list of posts they've recently viewed. I'm guessing the best route is to just add the post id to an array in their usermeta when they visit a post but I'm wondering how can I do that and still be able to show them a chronological order of posts in which they viewed them. And also I wanna clip the number of posts in the array keeping it at 20 posts or so that the array isn't out of control. Any ideas?


Set page template automatically based on parent

As the title implies, I'm trying to set each new page under X parent to a specific page template. Either through a function/plugin/code eg: if I make a 'swiss cheese' page, that is a children of the 'chesses' page, wp will automatically assign it the 'cheese' page template


WordPress Dashboard RSS Feeds New Window

I am trying to force the RSS Feeds available in the WordPress Dashboard to open in a new window. I have tried several plugins, but most are focused on working with posts/pages/comments and not not working to fit my needs. What is the best approach to force all external dashboard links to open in a new window? Thanks for your help. JL


How to allow empty title for attachments?

* When adding an image attachment to a post, the Title field is always filled automatically with the file name.   * For some images I change this into something more meaningful, for other images I want this field to be empty (in my theme I'm displaying this title field as a caption below each image, but not all images should have this caption).   * However, if I clear the Title field, it shows again the file name upon save - with the message " **Empty Title filled from filename.** "   * Any ideas how to change this behaviour, or suggestions for a workaround? I could use the Alt field or Caption field, but I prefer using the Title field - so my client can already fill in the titles by changing the filenames before upload.


Wordpress Settings API not saving options

I just started learning the Wordpress Settings API and things are not as easy as I first tought.I have created a section and two fields and it seems that the fields are not saving the data.Each time I click on the field the data gets deleted.Here is my code:               <?php         function thanathos_theme_menu(){             add_menu_page(                             'Thanathos',                             'Thanathos',                             'administrator',                             'thanathos_menu_id',                             'thanathos_menu_display_callback'                          );             add_submenu_page(                             'thanathos_menu_id',                             'Blog Page',                             'Blog Page',                             'administrator',                             'thanathos_social_logo_options',                             'thanathos_menu_display_callback'                          );         }         add_action('admin_menu' , 'thanathos_theme_menu');              function thanathos_menu_display_callback(){     ?>

Thanathos Theme Options
                 <?php settings_errors(); ?>                 <form method="post" action="options.php">                      <?php settings_fields( 'thanathos_social_logo_options' ); ?>                       <?php do_settings_sections( 'thanathos_social_logo_options' ); ?>                     <?php  submit_button(); ?>                 </form>
     <?php }?>     <?php         function thanathos_initialize_social_logo_options(){             if(false == get_option('thanathos_social_logo_options')){                 add_option('thanathos_social_logo_options');             }                    add_settings_section(                         'logo_social_section',                         'Logo & Social Options',                         'logo_social_section_callback',                         'thanathos_social_logo_options'                     );             add_settings_field(                         'logo_field',                         'Logo URL',                         'logo_field_callback',                         'thanathos_social_logo_options',                         'logo_social_section'                     );             add_settings_field(                         'facebook_field',                         'Facebook URL',                         'facebook_field_callback',                         'thanathos_social_logo_options',                         'logo_social_section'                     );             register_setting(                         'thanathos_social_logo_options',                         'thanathos_social_logo_options'                     );         }         add_action( 'admin_init', 'thanathos_initialize_social_logo_options' );         function logo_social_section_callback(){}              function logo_field_callback(){             $option = get_option('thanathos_social_logo_options');              echo '<input type="text" id="logo" name="thanathos_social_logo_options[logo_field]" value="' . $options['logo_field'] . '" />';         }          function facebook_field_callback(){             $option = get_option('thanathos_social_logo_options');              echo '<input type="text" id="facebook" name="thanathos_social_logo_options[facebook_field]" value="' . $options['facebook_field'] . '" />';         }     ?>


assign the returned value of wordpress function to a variable?

Why can't I store wp_list_categories in a variable?                       $wplist =   wp_list_categories( array (                                 'taxonomy'  => 'ntp_package_type',                                 'pad_counts'=> 0,                                 'title_li'  => '',                                 )                 );     var_dump($wplist); //null


How to hide a custom post type

I've got a wordpress website and i need to hide for the moment some custom post type. I want to hide it because we will need it later. How do I do it?


How to automatically create a custom field when a post is published?

I'm trying to add custom fields on post publish with this code which I added to my functions.php :               add_action('publish_page', 'add_custom_field_automatically');     add_action('publish_post'. 'add_custom_field_automatically');     function add_custom_field_automatically($post_ID) {         global $wpdb;         if(!wp_is_post_revision($post_ID)) {             add_post_meta($post_ID, 'FIELD_NAME', 'CUSTOM VALUE', true);         }     }      This code should work but it doesn't ? I updated field and custom value but custom fields are never created.Why ?


Why does WordPress 3.0.4 keep deleting the contents of the .htaccess file?

I just installed WordPress 3.0.4 on a GoDaddy hosted server. And I've been having a problem with my .htaccess file. For some reason, WordPress automatically erases all the mod_rewrite configuration settings in .htaccess file whenever I view the WP admin page for setting permalinks. Deleting the .htaccess file kinda defeats the purpose of that page. I've been able to do create a workaround by just manually entering the configurations into the .htaccess file and never visiting the permalink configuration page. But this doesn't feel like a good solution. Can anyone share thoughts about what might be causing this? Thanks! David


Load jQuery only on home page

I am working in a premium wordpress theme... It is a complex wordpress theme with lots of admin features so i feel very difficult to edit... Now i need to move a sidebar upwards only in homepage... i use this code...               .classname{       position:relative;       top:-300;     }      But the code above is moving the sidebar on all pages... since the site is complex i don't know where to add specific class name for sidebar in homepage... So i decided to use jQuery to find whether the page is home page or not... if it is homepage then i move the sidebar upwards, else not... Please say me how to find whether the page is homepage or not using jQuery...


Custom page template to display all image attachments

I am tryin to insert all pictures in media to page. By meaning all pictures, everything added in blog. I ve been looking this feature all day. Is there any shortcode for that or something easy to make it? Thanks in advance.


wordpress multisite, how to keep user on subdomain throughout registration process?

I am running wp subdomain multisite in combination with domain mapping. This means I can create a new subdomain site xyz.site.com and map the domain name 'xyz.com' to that site. The problem I have is someone clicks 'register' on the subdomain mapped site 'xyz.com' and they are sent to site.com to register. This is VERY confusing to many people and I'm getting tired of the complaints. How do I setup wp multisite, so that if a person wants to register on a subdomain site, that they do not leave that site at any point? _I use multisite to host multiple client sites, all which have their own domain names. I simply 'map' the domain name to their subdomain site. This means that users who come to one clients site to register, are being sent to the primary site to register, which is just plain wrong and confusing_


get_query_var( 'paged' ) not working outside of homepage

Twenty Eleven Theme... On the home page, I have successfully filtered the loop to display just "Featured" posts with pagination functioning properly through nav links. I'm trying to display posts from all categories on another page called "Unfiltered." Why do the nav links disappear when used on this other page? edit: if I change the value of 'paged' to '1' or '2', I get the 10 posts that I would expect to so 'paged' seems to work depending on the value I set, just not when I set it to get_query_var( 'paged' )                           <?php /* $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;*/                      $unfiltered_query = new WP_Query (                       array (                     'posts_per_page' => 10,                     'paged' =>  get_query_var( 'paged' )                 )                   );?>                  <?php if ( $unfiltered_query->have_posts() ) : ?>                      <?php twentyeleven_content_nav( 'nav-above' ); ?>                      <?php /* Start the Loop */ ?>                          <?php while ( $unfiltered_query->have_posts() ) : $unfiltered_query->the_post(); ?>                          <?php get_template_part( 'excerpt', get_post_format() ); ?>                      <?php endwhile; ?>                      <?php twentyeleven_content_nav( 'nav-below' ); ?>


How to override javascript files in child theme?

I'm loading some javascript files in the parent theme. The path in the parent theme is "scripts" > "custom.js". In the child theme, I'm creating the same path (scripts > custom.js) and changing some of the jQuery inside the custom.js file. The problem is that the changes are not being applied. Is this the wrong way to make changes to these files in the child theme?


Network - My sites are unavailable

I'm asking you your help because I created a network websites :   * example.com/site1/   * example.com/site2/ The installation was done and the tab "My Sites" is available with both websites. I applied the same Alpine theme to the websites. However, I don't know if i must to upload some file in the directories /site1 and /site2 to the FTP server. The directories are empty. If i open the url http://www.example.com/site1/ I got this : ![a busy cat](https://imagizer.imageshack.us/v2/541x142q50/537/UPLYr5.jpg) On the site1 Dashboard, a page is created and configured to be displayed by default as a static page : ![a busy cat](https://imagizer.imageshack.us/v2/522x184q50/537/5JKYOH.jpg) Thank you very much for your advices (and sorry for my poor english!). Best regards, Lionel


Get parently level taxonomy based on published posts that have child taxonomy?

I have a CPT Properties and a taxonomy Regions. So a Region is something like:   * Florida      * South Gulf Coast        * Anne Marie Islands       * Cape Coral  Generally only the third level will ever be selected in a post. I'm to create select drop downs based on the top parent level or second level though. I only want to grab taxonomy who's child (or child of a child) has a PUBLISHED post attached to it. I'm not quite sure what to use to do this. Any suggestions?


Where is the old post permalink slug stored?

I published an article with permalink slug:               http://domain.com/writing      Then after publishing, I changed the permalink slug to `writing-lorem`. Now, whenever I visit `/writing`, it redirects to `/writing-lorem`. I want to use the `writing` slug for a new category but can't, it changes to `writing-2`. To attempt to remove all records of the `writing` slug, I looked in the DB for the `post_name` column under that post, but the value was the new slug `writing-lorem`. Then I search for other posts with the `writing` value, none found. Where exactly is that slug stored and how can I remove it so that I can use it for the category?


Making a Custom Menu Sidebar Icon show as Current in css

In the custom WP Menu I have assigned classes which are different for each menu item. For example               .power-icon a {         padding-left: 35px !important;         background-image: url(/images/icon-grey.png);         background-position:  5% 50% ;         background-repeat: no-repeat;      }          .power-icon a:hover {         padding-left: 35px !important;         background-image: url(/images/icon-blue.png);         background-position:  5% 50% ;         background-repeat: no-repeat;      }      This works fine, however, I would like to make the blue icon also display when the page is active/current. I discovered that this                     .widget_nav_menu .menu .current-menu-item {                  background-color: #f3f3f3;                }      will highlight the current item background. But my attempts to unify it with the icon class have failed. Appreciate any help on this. Thanks.


Saving the current state of a checkbox that I have added to my admin 'edit a category' page?

I have been struggling with this for two days. I've added an input(checkbox) to represent "Featured" categories on the 'Create a category' and 'Edit a category' pages. My problem is that when I update or create my category, the status of the checkbox(i.e. 'checked') doesn't persist. I have two other fields that I've added(one for numbers, one for text) and both of those work perfectly. To save the checkbox state, I'm using the same code that I use to save the number and text fields to my database. I think that's where I'm having a problem, as I'm not sure if I'm grabbing the right field from the checkbox. I'm pretty new to all of this, first website. Hopefully one of you more knowledgeable folks can lend me a hand, here's my code: Adding the checkbox to the 'create a category' page:               // Adding 'Featured' checkbox to CREATE category page          function taxonomy_add_new_featured_checkbox() {     ?>
         Featured         <input type="checkbox" name="term_meta[featured_checkbox]" id="term_meta[featured_checkbox]">
Check this box to mark this category as a "Featured" category

     <?php     }     add_action( 'category_add_form_fields', 'taxonomy_add_new_featured_checkbox', 10, 3 );      Adding the checkbox to the 'edit a category' page:               // Adding 'Featured' checkbox to EDIT category page     function taxonomy_edit_featured_checkbox($term) {     // put the term ID into a variable     $t_id = $term->term_id;          //retrieve the existing value(s) for this meta field. This returns an array     $term_meta = get_option( "taxonomy_$t_id" ); ?>
         Featured	                      <input type="checkbox" name="term_meta[featured_checkbox]" id="term_meta[featured_checkbox]" <?php checked( $term_meta['featured_checkbox'], 1); ?> />
Check this box to mark this category as a "Featured" category

     <?php     }     add_action( 'category_edit_form_fields', 'taxonomy_edit_featured_checkbox', 10, 3);      The code to save these changes:               // Save extra taxonomy fields callback function     function save_taxonomy_custom_meta( $term_id ) {         if ( isset( $_POST['term_meta'] ) ) {             $t_id = $term_id;             $term_meta = get_option( "taxonomy_$t_id" );             $cat_keys = array_keys( $_POST['term_meta'] );             foreach ( $cat_keys as $key) {                 if ( isset ( $_POST['term_meta'][$key] ) ) {                         $term_meta[$key] = $_POST['term_meta'][$key];                 }             }             // Save the option array             update_option( "taxonomy_$t_id", $term_meta );         }     }     add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 3 );     add_action( 'create_category', 'save_taxonomy_custom_meta', 10, 3 );      Thanks for reading!


Backup blog posts only

I have a Wordpress site with a lot of pages and blog posts. I want to create a new site but keep all blog posts, just blog posts and no pages. How can I achieve this? When I backup the database from mysql, everthing will pass to the new site, but I just want to backup blog posts. WordPress Backups


Remove fields on media uploader for custom page type - not working for "From Computer" or "From Url" tabs?

This code works for me if I go to upload a file and choose the **Gallery** or **Media Library** tabs then it correctly hides elements on the page. If I go to the **From Computer** or **From URL** tabs, nothing is hidden! If I take out the if statement then it works. I can't see why it shouldn't be working on these 2 tabs as the URLs are the same apart from the tab parameter and the if statement is only checking the post_id: **Gallery tab** works: /wp-admin/media- upload.php?post_id=4&type=image&tab=gallery **From Computer** tab doesn't work: /wp-admin/media- upload.php?post_id=4&type=image&tab=type **Edit** On pages using my custom post type I am passing through the parameter of type=image to the media uploader. For 2 of the tabs my code within the if statement is not being executed: ![2 tabs still showing all information](http://i.stack.imgur.com/Aic4x.jpg) The other 2 tabs on the media uploader popup do what I want: ![Code running correctly](http://i.stack.imgur.com/C0vrw.jpg) If I have the if statement as:               if ($_GET['type'] == 'image')      Then it still doesnt trigger the code on **From Computer** or **Gallery Tab** so I can't rely on the querystring? Any ideas?


Get posts from 2 or more categories

I'm trying to get posts from 2 or more categories, so far I discovered:               $args = array(          'category__in'=>array( implode(ot_get_option("beautiful_categories"), ",")  )     );     $query = new WP_Query( $args );      I'm using OptionTree and that will return categories ids with "," between them. and then I get post with while loop, but it just return posts of first category. How can i fix it?


After updating WP keeps nagging about a newer version. Why?

I updated WP to version 3.9.2 (currently the latest) via Git which works fine. However, in the admin it keeps on telling me “a newer version is available”. After some digging somehow it appears to be related to the language pack. I’ve got `WPLANG` set to `nl_NL`. In the `wp-includes/update.php` file `wp_version_check()` checks against the WordPress server for newer versions using a URL like this: http://api.wordpress.org/core/version- check/1.7/?version=3.9.2&php=5.5.11&mysql=5.5.15&local_package=&blogs=1&users=2&multisite_enabled=0&locale=nl_NL Click it and you’ll notice it offers a response with the status “upgrade”, yet the version is the same!? If you remove locale argument at the end or leave it empty (URL below), you’ll see it will answer with a status value of “latest” and thus not triggering update nags. http://api.wordpress.org/core/version- check/1.7/?version=3.9.2&php=5.5.11&mysql=5.5.15&local_package=&blogs=1&users=2&multisite_enabled=0&locale= I tried flushing the WP cache (update transients) but nothing changes. Anybody gets what is going on here? Thanks.


How to edit blockquote image

I'm using TinyMCE Advanced, to show more options to edit text. When I use the `blockquote`, an image appear, like this: ![enter image description here](http://i.stack.imgur.com/0pF2Z.png) How can I change this?


Auto populate a Form

I'd like to auto populate a form / Text area with the post content ! **For Example :** The link below has got a link which take it to the form !               http://cozysms.com/passenger-tumne-mere-jeb-me-hath/      When somebody click at the link - Send Sms Now just below the social buttons it will take it to the form -               http://cozysms.com/send-free-sms/      I want to auto populate the form with - the_content() of the `www.cozysms.com/passenger-tumne-mere-jeb-me-hath/` Similarly for other articles. Is this doable?


List of users inside custom taxonomy

So I'm trying to get a list of terms inside a taxonomy that is related to users. Inside each term (think a sub list) should be a list of the users for that term. Here is the code I've been working with. But it returns several errors for the query and non-object issues. Help?               <?php $disciplines = get_terms('disciplines');       foreach($disciplines as $discipline) {         echo '
' . $discipline->name . '
';              $post_args = array( 'post_type'  =>  'users', 'disciplines' => $discipline->term_id);         $posts = get_posts( $post_args );              foreach( $posts as $post ){           echo 'post title: ' . $post->post_title . '
';         }       }          ?>


is_home() vs is_archive()

I have set my front page set to be a static front page, "Home," and my Posts page is set to my "News" page. When on my News page, `is_home()` returns `1` as expected but `is_archive()` returns `0`. I would expect that it would return `1` also. The WP doc for `is_archive()` doesn't make it clearer for me. It reads, > checks if any type of Archive page is being displayed. An Archive is a > Category, Tag, Author or a Date based pages. I would expect that to be true. Something isn't connecting for me. What is the difference between `is_home()` and `is_archive()`?


How do I rewrite this loop as a new WP_Query style-loop?

How do I rewrite the `if (have_posts()) : ... while (have_posts()) : the_post();` style Wordpress loop below as a new_query style-loop using `<?php $the_query = new WP_Query();`? ( As shown in http://codex.wordpress.org/Class_Reference/WP_Query ) The current loop below alternates post classes to display a grid of posts two posts wide (see image below). But I need to rewrite it using a new query so I can: 1) add a post display count, and 2) a post count offset to it. The reason is I need to use it in the page template with another loop based on new query. This loop alternates the class between "uneven post" and "post" to display the posts (see in the image below.) I need to retain that function in a new WP_Query loop.               <?php              if (have_posts()) :         $odd = false;         while (have_posts()) : the_post();         $odd = !$odd;         ?>              <div class="<?php if ($odd) echo 'uneven '; ?>post">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
              <?php the_excerpt(); ?>
              <?php endwhile; else: endif; ?>      _The loop above displays posts like this:_ ![enter image description here](http://i.stack.imgur.com/SCKQO.jpg) This is a standard new WP_Query loop:               <?php $my_query = new WP_Query('offset=5&showposts=10'); ?>          <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>          <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">          <?php the_title(); ?>


the_editor() function

I'm writing a WordPress plug-in that requres user input, so I thought I'd try and use the default WordPress rich-text-editor. Firstly so as not to have to include a text editor in my plug-in when WordPress already has one, and secondly so it's more seamless for the user. I literally just want the default editor, nothing changed or customised about it. The problem is, I can't get it to work without errors, and there is little to no documentation on the `the_editor()` function. At the moment I have this where my textbox should be:               <?php       the_editor( $content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2 );       ?>      And the editor appears, but with errors. For example the Visual/HTML looks broken, and the media buttons do nothing. I mean, you click them and nothing happens. Example here


Include Entire Custom Page Template On Another Page

I am trying to create a "one page slider" where I am creating a custom page template to display multiple pages that I specify. (yes I know there are themes for this- I want to customize it myself) I have looked at examples of how to display a one page onto another page such as Proper way to get page content & Wordpress: include content of one page in another. I have pages A, B, & C. I want to display pages B + C on page A below the content on page A. So created a custom page template for each page. I want to include the post_content from page B as well as other images that I have within my custom page template for page B on to page A. My current php code on custom page template page A (displays page B on page A) is:               $id = '2';     $include = get_post($id);     $content = apply_filters('the_content',$include->post_content);     echo $content;      This is great and displays content but how can I query my images from custom page template page B? Here is the code for my image


The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?

Lately I've been reading about MariaDB and Percona Server, two strong alternatives to MySQL that have gained popularity since Oracle bought Sun. As far as I know, both of them could be used with WordPress, but I'd like to know if anyone uses them, and if they really help make our blogs and servers run better than they did with MySQL.


Email Obfuscation: Is antispambot() Acceptable?

I've been looking into Email Obfuscation and trying to get away from obfuscation plugins when I ran across this code snippet[1]:               function remove_plaintext_email($emailAddress) {         $emailRegEx = '/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4})/i';         return preg_replace_callback($emailRegEx, "encodeEmail", $emailAddress);     }     function encodeEmail($result) {         return antispambot($result[1]);     }     add_filter( 'the_content', 'remove_plaintext_email', 20 );     add_filter( 'widget_text', 'remove_plaintext_email', 20 );      For me, this pretty much replaces any obfuscation plugin out there in a few lines of code which is always good. My concern is the way `antispambot()` tries to hide the email via converting it to HTML Entities. My question is, is that enough to stop spambots from grabbing the email? This function has been around for so long I just wanted to make sure it was still valid to use or if there was a better way to hide emails from spambots. [1] Source


Recommended Books on WordPress for Management and non-Developers?

I've had a few non-technical clients have a tough time with WordPress' admin UI. One of them asked me today if there were any books that could help someone like him - someone who is only concerned with writing content. All of the WordPress books I've seen are either targeted toward developers, or have a lot of technical content. What may work best for him is a book that explains terms such as _"categories"_ , _"pages vs posts"_ , _"widgets"_ , etc. _On a side note, it would seem to me that as tools like WordPress get adopted by a larger audience - including non-web-savvy people - there's a great opportunity for a set of guides aimed specifically at content creators and not developers._ Do you know of any books that can help a non-technical, non-web-savvy person write, edit & manage the content of their WordPress-powered site?


if specfic language content is empty then hide language flag by qTranslate

My site has 2 more language but one language content is empty or one of my page's content is empty for specific one language. So i want to hide or don't show language flag in my wordpress site. Is it possible? if possible the how can i implement this.


Best practices for localizing WordPress content?

A client asked for a blog that will have localized content (i.e. en.blogname.com for English content, fr.blogname.com for French content, etc). Being new to building such a blog, we recently discovered WPML and qTranslate, which look perfect for our needs. Do you have any best / recommended practices for setting up a multilingual blog? At this point, we don't envision the need to have the WordPress software translated, but if you've found that to be a good idea, we would love to know. The authors will all be multilingual (English + one other language), but it's conceivable that non-English speakers may be hired later.


Blog template PHP

Here's the WP wordpress website: http://www.joaoalexandre.com/wordpressteste/ And here's the Blog section: http://www.joaoalexandre.com/wordpressteste/artigos/ How can I show a regular simple blog with posts and maybe categories and get rid of the extra garbage it currently has (slider, "Services" etc)? I suppose the answer lies in creating a new template for this "Artigos" page (which is the blog)?


Localization Problem: Doesn't Display Translated Words

I'm trying to localize my plugin and with a plugin called CodeStyling Localization, I succeeded to create a .po file. However, the words used in my plugin remain in English although the default language is set to Japanese as defined in wp-configdefine('WPLANG', 'ja'); Other localized plugins are properly translated including, Yet Another Related Posts Plugin and WP Multibyte Patch. This is a sample plugin I wrote to test plugin localization. I kept it as simple as possible. **wp-content\plugins\localizationsample\localizationsample.php**               <?php     /*           Plugin Name: Localization Sample Plugin         Version: 1.1         Author: Teno     */          // Localization     add_action('init', 'localizationsample_init');     function localizationsample_init() {         $loaded = load_plugin_textdomain('localizationsample', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/');     }           // Add Admin Menu      add_action('admin_menu','localizationsample_menu');     function localizationsample_menu() {          add_options_page(             'Localization Sample Plugin',                'Localization Sample Plugin',                    'manage_options',                    __FILE__,                            'localizationsample_adminpanel'         );     }     function localizationsample_adminpanel() {         echo '

';         echo '
' . __('hi!', 'localizationsample') . '
';    // "hi!" should be translated.         echo '

';     }     ?>      **wp-content\plugins\localizationsample\lang\LSample-ja_JP.po**               msgid ""     msgstr ""     "Project-Id-Version: Localization Sample Plugin v1.0\n"     "Report-Msgid-Bugs-To: \n"     "POT-Creation-Date: 2012-08-17 20:23+0900\n"     "PO-Revision-Date: 2012-08-17 11:27:39+0000\n"     "Last-Translator: \n"     "Language-Team: \n"     "MIME-Version: 1.0\n"     "Content-Type: text/plain; charset=UTF-8\n"     "Content-Transfer-Encoding: 8bit\n"     "Plural-Forms: nplurals=2; plural=n != 1;\n"     "X-Poedit-Language: \n"     "X-Poedit-Country: \n"     "X-Poedit-SourceCharset: UTF-8\n"     "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"     "X-Poedit-Basepath: .\n"     "X-Poedit-Bookmarks: \n"     "X-Poedit-SearchPath-0: Z:/xampp/htdocs/wptest/wp-content/plugins/localizationsample\n"     "X-Textdomain-Support: yes"          #: localizationsample.php:28     #@ LSample     msgid "hi!"     msgstr "やあ！"      Both files are saved as UTF-8 without BOM. What am I doing wrong? *updated the code but the issue still persists.


How to force Media manager to overwrite files of same name?

I have a widget that works with my theme that expects images named in a certain way, slide1.png, slide2.png, etc... However, when the user uploads their own images, named slide1.png, slide2.png, etc to the media library, rather than updating the images with the new ones, WordPress changes the names of the replacement images to slide11.png, slide22.png, etc Can I set a filter in theme options that tells WP to overwrite existing images without changing the filenames?


Website not listed under Sites (in a Network environment)

I have a Wordpress network installed, and the first website I created is not listed under the Sites entry in the top horizontal menu. The second website I created is, along with the parent website. If I go to Network > Sites, the first website is listed, and I can use the website fine, provided I type in the URL directly into the address bar. Do you know the best method to add the site back into the Sites menu entry at top?


wp_update_user not updating

In desperation I am asking for help in this forum too - if someone (ANYONE!) could take a look a this post and see if they could help I'd be eternally grateful http://wordpress.org/support/topic/wp_update_user-not-updating?replies=11 Basically - I am updating a user's role and capabilities via script but the changes only come in to effect (ie the user can see specific menu items) when I go into that user and hit "save" Thanks in anticipation!! Chris **UPDATE:** Maybe this helps solve it? **This is the WP_User object I have echoed out on screen when logged in as the newly changed user** :               WP_User Object ( [data] => stdClass Object ( [ID] => 130 [user_login] => test [user_pass] => $P$BuHO1ABLCNQ716tktgyes4jqqkfVxG. [user_nicename] => test [user_email] => email@gmail.com [user_url] => [user_registered] => 2012-07-19 12:07:52 [user_activation_key] => [user_status] => 0 [display_name] => test ) [ID] => 130 [caps] => Array ( [editor] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => editor ) [allcaps] => Array ( [upload_files] => 1 [unfiltered_html] => 1 [edit_posts] => 1 [edit_published_posts] => 1 [publish_posts] => 1 [edit_pages] => 1 [read] => 1 [level_7] => 1 [level_6] => 1 [level_5] => 1 [level_4] => 1 [level_3] => 1 [level_2] => 1 [level_1] => 1 [level_0] => 1 [edit_published_pages] => 1 [publish_pages] => 1 [manage_options] => 1 [view_menu] => 1 [editor] => 1 ) [filter] => )      **This is how the menu item is being created in my plugin file (which should display to the user):**               add_menu_page('Welcome', 'Welcome','edit_posts', 'welcome', 'welcome_page', get_bloginfo('template_url').'/images/icon.png', 0);      **This is the function / page that the menu item returns:**               function welcome_page()      {         global $currrent_user;     if(!current_user_can('edit_posts'))     {              print '

Your account has been restricted, most likely due to an unpaid subscription.
';     }     else     {         include 'welcome-page.php';     }      }      As you can see - the user only needs edit_posts capability to view the menu item and for the function to return the welcome page. The user indeed has this capability, but cant do either of these things - unless i click "save" as admin in the user-edit page?? **Edit 2** **The following are all the different approaches I have taken to change the user role - if it helps!**               //using this currently     $user = new WP_User($unpaid->uid);//$unpaid->uid is the users ID     $user->set_role('editor');     if(!$user->has_cap('edit_posts'))     {     $user->add_cap('edit_posts');     }     wp_cache_delete($unpaid->uid, 'users');          //another attempt     $uID = $unpaid->uid;     wp_insert_user(array('ID'=>$uID,'role'=>'editor'));       **UPDATE AGAIN!** I have just tried this and again, the db is updated, even shows 'editor' in the admin panel, but the user still cant see the appropriate menu items unless I click "update" on their profile!               $new = new WP_User($current_user->ID);     $new->set_role('editor');          wp_cache_delete( $new->ID, 'users' );     wp_cache_delete( $new->user_login, 'userlogins' );     wp_cache_delete( $new->user_email, 'useremail' );     wp_cache_delete( $new->user_nicename, 'userslugs' );     do_action('profile_update');      Any thoughts?