Custom Post Type - Same Post Name, Different Post Type

I have 4 Custom Post Types:   * Services   * FAQs   * Prices   * Before and After I want to be able to have the same post names within each of these post types, example: > Services   >  Skin (example.com/Services/skin)   >  Cream (example.com/Services/cream)   >  Body (example.com/Services/body) > > FAQs   >  Skin (example.com/FAQs/skin)   >  Cream (example.com/FAQs/cream)   >  Body (example.com/FAQs/body) > > Prices   >  Skin (example.com/Prices/skin)   >  Cream (example.com/Prices/cream)   >  Body (example.com/Prices/body) > > Before and After   >  Skin (example.com/before-and-after/skin)   >  Cream (example.com/before-and-after/cream)   >  Body (example.com/before-and-after/body) How can I do this? Right now if I make a new post with the same name as a current one, it adds a "-2" or "-3" to the end of the posts slug: BAD: > example.com/services/body > > example.com/faqs/body-2 > > example.com/prices/body-3 > > example.com/before-and-after/body-4               add_action('init', 'create_post_type_html5'); // Add our HTML5 Blank Custom Post Type     function create_post_type_html5()      {       register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category     register_taxonomy_for_object_type('post_tag', 'html5-blank');     register_post_type('html5-blank', // Register Custom Post Type         array(         'labels' => array(             'name' => __('Services', 'html5blank'), // Rename these to suit             'singular_name' => __('Services', 'html5blank'),             'add_new' => __('Add New', 'html5blank'),             'add_new_item' => __('Add New Services', 'html5blank'),             'edit' => __('Edit', 'html5blank'),             'edit_item' => __('Edit Services', 'html5blank'),             'new_item' => __('New Services', 'html5blank'),             'view' => __('View Services', 'html5blank'),             'view_item' => __('View Services', 'html5blank'),             'search_items' => __('Search Services', 'html5blank'),             'not_found' => __('No Servicess found', 'html5blank'),             'not_found_in_trash' => __('No Service\'s found in Trash', 'html5blank')         ),         'rewrite' => array('slug' => 'service','with_front' => true),         'public' => true,         'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages         'has_archive' => true,         'supports' => array(             'title',             'editor',             'excerpt',             'thumbnail'         ), // Go to Dashboard Custom HTML5 Blank post for supports         'can_export' => true, // Allows export in Tools > Export         'taxonomies' => array(             'post_tag',             'category'         ) // Add Category and Post Tags support     ));                }


Making a Custom Post Type Publish Loop

I want to re-publish all previously published products of a custom post type. Let's say the post type is "events" This is what I was thinking something like this:               $args = array(     'post_type' => 'events',     'post_status' => 'publish', // get only published posts?     'posts_per_page' => -1     );     $posts = new WP_Query( $args );     if ( $posts -> have_posts() ) {     while ( $posts -> have_posts() ) {          wp_publish_post(NEED TO GET ID)     }     }                wp_reset_query();      The thing I can't figure out how to get the id in the loop or how to get just published posts (took an educated guesss) * _Edited *_               $args = array(     'post_type' => 'events',     'post_status' => 'publish', // get only published posts?     'posts_per_page' => -1     );     $posts = new WP_Query( $args );     if ( $posts->have_posts() ) {     while ( $posts->have_posts() ) {         $posts->the_post();         wp_publish_post($post->ID)     }     }


WP is not allowing me to post Macintosh .pages documents to my blog

I'm completely green when it comes to website development, therefore, if you do have an answer for me could you please explain it in laymen's terms. My problem:   I just created a blog post using .pages, this document includes illustrations and a preselected design layout as well as a couple pages of content. I think it's just a matter of WP not recognizing the format. When I go to the post and try to add the .pages document with the media upload I get this message... > "Sorry, this file type is not permitted for security reasons." When I just copy and paste the each page individually into the post it views fine but when I publish and update the post the material is only viewed as a blue square with a question mark. I've read about similar issues experienced by others but it was concerning multi sites and I don't believe that my webpage is a multisite. See www.suttonsez.com.   When I go to my dashboard and look under Settings there isn't an option for adding extensions. Is there a way to do what I want?


Disable block with taxonomies at post page

I am developing an events manager for Wordpress. I have post_type = 'event' and taxonomy 'event_place' And I want delete block with taxonomy select in post page, because user can do it at custom metabox. ![enter image description here](http://i.stack.imgur.com/aBKBY.png)


WordPress Not Using Template Files After Permalink Update

I have a really weird issue that just occurred on a client site. I updated the permalink structure from /%category%/%postname%/ to /%postname%/ and suddenly my pages don't respect templates and are defaulting to index.php. What else is strange is index.php is attempting to display the latest blog post of the site and not the actually page you are on, for example /about-us/ is not using template-about.php it is using index.php with the latest blog post content. I have deleted and rebuilt the htaccess file, flushed the rewrite rules and nothing is happening. If I set permalinks to Default(/?p=123) the site works just fine. Does anyone have any ideas? I am at the end of this very large project and I have no idea what to do! -d


Import custom taxonomies

I have a list of custom taxonomies. I have more than 1000 taxonomies to added. I can't find a plugin to import custom taxonomies. Is there a way to insert directly into MySQL database? If so how can I write the insert statement to insert taxonomies. Regards, Alex


How can I receive the image id using the media box?

The code below allows me to retrieve the image string, when `Insert to Post` has been pressed, but what would be the correct way to retrieve the ID of the image? So I can retrieve all information through `wp_get_attachment_image_src`?               jQuery(document).ready(function() {              var form_field;         var upload_field_ID = '';              jQuery( '.upload_image_button' ).click( function() {                  jQuery( 'html').addClass( 'Image' );                  upload_field_ID = jQuery(this).prev('input');             form_field      = upload_field_ID.attr( 'name' );                  tb_show( '', 'media-upload.php?type=image&TB_iframe=true' );                  return false;              });              window.original_send_to_editor = window.send_to_editor;         window.send_to_editor = function( html ) {                  if (form_field) {                 var image_url = jQuery( 'img', html ).attr( 'src' );                 upload_field_ID.val( image_url );                 tb_remove();                 jQuery( 'html').removeClass( 'Image' );             } else {                 window.original_send_to_editor( html );             }              }          });


Index showing source code

Suddenly the wordpress showing the source code when I click the url address, and I get this > The code is just the site offline plugin i have so i can set the site > offline So the problem is that doesn't parse the code to html/php but show it as plain source code...


Set language from url?

I used mlanguage plugin for Multi language website. How can I pass the parameters in URL? Examples:               www.example.com/?lang=bm     www.example.com/?lang=en


How do I rename a category in the menu bar only?

I'm surprised this hasn't been asked before, but I couldn't find it via search. I'd like to do:               Full Category Name -> Text in Menu Bar     Exercise Tips -> Tips     Reviews of Exercise Equipment -> Reviews     Industry News -> News      So the menu bar looks like: `Tips | Reviews | News` But when you're in the actual category, it shows the full title. What I need is a "Navigation Name" field in the category setup screen. Is there a way to do this, perhaps with a plugin?


List a custom post type's posts ordered by nested custom taxonomy

Like the title says I have custom post types and custom taxonomy for that type.   For the Taxonomy I have terms in 3 levels like this:   * -> Term 1   * --> Term 1a   * --> Term 1b   * -> Term 2   * --> Term 2a   * --> Term 2b   * ---> Term 2b-1   * ---> Term 2b-2 Now when I visit the page for Term 2, it shows all the posts under that Term. But how to make these posts as nested list corresponding to those levels? And also showing the title for each. So the list would look something like this:

Term 1:

Post 1

Post 2

Term 2:

Post 3

Term 3:

Post 4

Post 5

Post 6

      I'm a bit lost as the query has happened already and all the needed posts are returned so I probably shouldn't make another call. Can I format this list using the info from the query or do I need to get all my taxonomy terms and then do for each finding children and corresponding posts?   And of course I don't want duplicate posts for each level.


wordpress random widget widget

am planning a random widget for widgets that uses jquery to fade in each widget from the top (a total of 12 displayed 3 at a time). The widget creation and animation I can handle but falling short on how it would choose a random order and display the 3 at a time. how can I achieve this? Any help on how to display random data and then pull the next random data would be amazing. thanks


Custom icons for Custom Post Type category lists

I need a simple way of assigning a custom icon whenever a category gets listed. I am using Custom Post Types and Taxonomies with Views and Types (plugins). For example, I have a Custom Post Type of Properties > and categories of Commercial/Residential/Hotels (each need an icon). Maybe assigning a class some how to each would be a good way... I think this would be a very useful thing for a lot of people so would really appreciate any thoughts/suggestions!


nonces in custom oop plugin

How to use the `check_admin_referer` method with oop?   If I use as it follows the function can not be called:               class MyClass{         function __construct(){                   if( isset($_POST['my_nonce_field']) && check_admin_referer('my_nonce_action', 'my_nonce_field')){                                $this->update_item();             }              }     }      $test = new MyClass(); The above leads to the following error message:               Call to undefined function check_admin_referer()


Get the url of attachments from the post?

I used the following code to get the images attached to a post                   $current_id = get_the_ID();         $rows = $wpdb->get_results("select guid from $wpdb->posts where post_parent = $current_id");              foreach ($rows as $row) {              ?>                  <a href="<?php echo $row->guid; ?>" data-titan-lightbox="on" data-titan-group="<?php the_ID() ?>"  style="display: none"><img src="<?php echo $row->guid; ?>" alt="Caption" class="Thumbnail thumbnail " width="228" height="160">              <?php         but this code only gives the images path with the folder containing the images. How can I get only the images from this loop?


Absolute path in Wordpress Network site

This site is part of a Wordpress Network. In the theme's CSS, I'd like to reference some font files using @font-face. The fonts live in the theme's directory. If I use a path like this: > http://brinkley.doig.com.au/wp-content/themes/brinkley/myriadpro- > boldcond.ttf , the file is not found. The true path is > http://www.doig.com.au/wp-content/themes/brinkley/myriadpro-boldcond.ttf , but using this path in the CSS does not work (see this answer). So, I have the problem of the true path not working in CSS, and the Wordpress network path not being found.


Wordpress custom jquery not found

I have a custom jquery file, here is code:               /* Custom JS */     jQuery(document).ready(function(){         jQuery("#top-menu li:first-child a").addClass('selected');     });      And here my code to load js file in functions.php               add_action('wp_enqueue_scripts', 'load_custom_scripts');          function load_custom_scripts(){         wp_enqueue_script('custom_script', THEMEROOT.'/js/custom.js', array('jquery'), true);     }      But when i check with firebug, my js not found. Hope anyone tell me what's wrong in my code? ![enter image description here](http://i.stack.imgur.com/iqGdQ.jpg)


Post timeline (pagination with date, not numbers)

I'm pretty lost... I'm hoping someone can lead me onto the right track! I'm trying to achieve the effect of a post timeline, by paginating the posts (1 per page) and rather than displaying the pages as numbered (i.e. 1, 2, 3, etc), I want to display the links as the date of each post, like this: LATEST << | **3 Mar** | **15 Feb** | **22 Jan** | **17 Dec** | >> OLDEST So far, I've looked at the built-in Wordpress functions 'get_pagination' and 'paginate_links', but I'm really struggling! Any help would be most appreciated. Thank you!


How to rearrange fields in comment_form()

Im using a custom filter to change the fields, but can´t figure out how to change the **order** of the fields in the comment form. Desired order:   * comment field (first/top)   * name   * email   * website This is the code which I am currently using:               function alter_comment_form_fields($fields){         $fields['comments'] = 'Test';         $fields['author'] = '
' . '' . __( 'Your name, please' ) . ' ' . ( $req ? '*' : '' ) .                         '<input id="author" name="author" type="text" placeholder="John Smith" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' />
';         $fields['email'] = 'next';  //removes email field         //$fields['url'] = '';  //removes website field              return $fields;     }          add_filter('comment_form_default_fields','alter_comment_form_fields');


Featured image for first post only

I'm currently having some difficulties showing a featured image for the first post only. Currently the image only shows if the post is the only post or if the post is a sticky post. (I realize this isn't the preferred code for displaying a featured image, but it was the only code I could come up with having a html5 template) AFAIK it shouldn't interfere with the code in question though. I hope someone could perhaps assist. This is the code I currently have:               <?php $count = 1; ?>     <?php while (have_posts()): the_post(); ?>     <article id="<?php echo $post->post_name; ?>" class="post<?php sticky_class(); ?>" itemscope itemtype="http://schema.org/Article">         <?php if ($count == 1): ?>         <?php if (has_post_thumbnail($post->ID)): ?>         <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'blog-thumbnail'); ?>         <a class="banner" href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" alt="<?php the_title(); ?>" itemprop="image">         <?php endif; ?>         <?php endif; $count++; ?>
<a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('%s', 'schema'), the_title_attribute('echo=0')); ?>" rel="bookmark" itemprop="url"><?php the_title(); ?>
                               <?php schema_posted_on(); ?>                  <?php if (is_archive() || is_search()): ?>         <?php the_excerpt(); ?>         <?php else: ?>         <?php the_content(__('Continue reading →', 'schema')); ?>         <?php wp_link_pages(array('before' => '
' . __('Pages:', 'schema'), 'after' => '
')); ?>         <?php endif; ?>         <?php edit_post_link(__('Edit', 'schema'), '
', '
'); ?>


Email notification via WP_Mail on published custom post type

I've been trying to get an email notification to fire when a new custom post type (in this case, "event"), is published. I've tried a few things and settled down to this simple example that, I imagine, _should_ work just fine.               function admin_event_notification()     {             $message = "Test";        wp_mail( 'jonathan@sabramedia.com', 'New Event', $message );               }     add_action( 'new_event', 'admin_event_notification', 10, 3 );      Any ideas what I'm missing? Once that works, the next step is accessing $post to get the title and permalinks, etc. I think I've got that covered, but any ideas are welcomed.


How do I allow certain users to make a certain type of post?

Here's a brief summary of how my site is setup: I have a relatively simple Intranet site. Right now I am utilizing posts as a means to provide news to users. I am also using pages. I only want certain users to be able to do these things (let's say "Editors"). What I would like to do is to setup a community section of the site where all users are able to make a post (to sell things, etc). I am wondering what the best way to go about this is? I could use a category to make it easy to show only these types of posts. But, I don't want users to be able to make any type of post. I only want them to be able to post to the community. If someone is posting news, I want them to have a higher security level. If I am thinking about this the wrong way, I'd love to hear other ideas! **Edit** : Here is my current custom post code:               function createCommunityPostType() {         $args = array(                 'public' => true,                 'label' => 'Community'         );         register_post_type('community', $args );     }     add_action('init', 'createCommunityPostType');


wp_insert_comment and security

**I am using wp_insert_comment to offer an in-house better ajax conditional comments interface. i got it all working great. my only question is.** What security measures should i take to make sure i leave security holes? the comments are submitted via ajax and so in the php file reciveing the data i use $_POST to collect data. How would you treat those inputs so make it bullet proof as possible and **I know how to secure forms so i am basicly asking:**   Does wp_insert_comment run (After submission) trough any other built in wordpress functions?


Widget to calculate time from a certain date

I'm trying to create a widget that will display the amount of time passed since a specific date, however I get this message: "function WP_Widget::widget() must be over-ridden in a sub-class." This is my first time writing a widget and my php knowledge is brutally limited. Thank you in advance for help and tips.


Dequeue script conditonnally

Was thinking about this : dequeue or enqueue scripts with IE for example. They say we can use `global $is_IE;` but that's wrong simply because it's not compatible with caching. Nowadays cache is everywhere ! Does someone have an idea about this? I mean if I want some styles in IE8 I can do this :               add_action( 'wp_head', '_load_ie_styles' );     function _load_ie_styles() {       global $wp_styles;       wp_register_style( 'ie8', get_stylesheet_directory_uri().'/css/style-ie8.css' );       $wp_styles->add_data( 'ie8', 'conditional', 'if IE 8' );       wp_enqueue_style( 'ie8' );     }      Ok that's cool ! Maybe if I want something to avoid IE I can do this (not tested) :               add_action( 'wp_head', '_load_ie_styles' );     function _load_ie_styles() {       global $wp_styles;       wp_register_style( 'not-ie', get_stylesheet_directory_uri().'/css/style-not-ie.css' );       $wp_styles->add_data( 'not-ie', 'conditional', 'if !IE' );       wp_enqueue_style( 'not-ie' );     }      But how to do this with scripts? How can I dequeue scripts condionnally (IE) ? Hope I'm clear. Does someone have any thought about this?


Update body class based on menu

I'm trying to add a class to the body tag based on whether current menu items either have children, or are children. The custom menu was added via `wp_nav_menu`. I have hooked into `wp_nav_menu_objects` via a filter, and am successfully detecting whether the current active menu item is a ancestor or child:               function has_submenu( $menu_items ) {              $current_id = 0;              foreach( $menu_items as $menu_item ) {                  // Get the id of the current menu item             if( $menu_item->current ) {                 $current_id = $menu_item->ID;             }             // if the current item has a child             if( $menu_item->menu_item_parent != 0 && $menu_item->menu_item_parent == $current_id ) {                 $body_class = 'has-submenu';                 break;             }             // if the current item has an ancestor             if( $menu_item->current_item_ancestor ) {                 $body_class = 'is-submenu';                 break;             }         }         return $menu_items;     }     add_filter( 'wp_nav_menu_objects', 'has_submenu', 10, 2 );      Now the issue i'm having is how to I then filter `body_class` to add the class?? I created the variable called $body_class, however i'm not sure hot to pass it to the `body_class` hook function. Make it a global variable? Create a class for all this? Thanks in advance!


Display Posts Query with IF function

I'm writing a template to display my custom posts types in a list. But I only want to have the post show if it has a value for one of my custom fields. I'll explain: My custom post type is "Faculty Members" and the Custom Field is "awards" The page will display all Faculty members who have received awards and what there awards are. Right now it is just posting All Faculty members thought the IF function is there so that my "Awards:" list is only displayed when there is a value. how can I apply this if function to all posts?               <?php/*Template Name: Prizes & Awards*/?>     <?php get_header(); ?>
     <?php query_posts( 'post_type=mtt_page'); ?>     <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>         <div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>

<?php the_title(); ?>
                 >                 <?php if ( has_post_thumbnail() ) { /* loades the post's featured thumbnail, requires Wordpress 3.0+ */ echo '
'; the_post_thumbnail(); echo '
'; } ?>
                     <?php the_content(); ?>     /*This is the custom field*/     <?php     $awards = types_render_field("awards", array("raw"=>"true","separator"=>"
", ‘show_name’ => ‘true’));     if( !empty( $awards ) ) {     echo "Prizes and Awards:
".$awards."
";}     ?>                      <?php wp_link_pages('before=
&after=
'); ?>

                    <?php endwhile; ?>


ThickBox width can't be changed in admin

I'm trying to make pop up in admin area (in post edit screen) and i can't make my thickbox wider then 670px (width: 670px). Here's my thickbox code that shows thickbox:               tb_show( ed.getLang('m7.popup_title'), '#TB_inline?width=800&height=600&inlineId=mygallery-form' );      (it works after clicking the tinyMCE button) and i get div with id="TB_window"               <div id="TB_window" style="width: 670px; height: 216px; margin-left: -335px; top: 48px; margin-top: 0px; visibility: visible;">      (code is from google browser) So if i manualy change width and then resize browser it gives 670px back to width.. Can it be somehow changed so that thickbox show all the content wich is 800px wide ? it creates insede #TB_window div with id="TB_ajaxContent" wich is 800px wide


How to not have the items of the subtaxonomy within the parent taxonomy

What I'm trying to do: Have a script that will go trough every taxonomy of a custom post type, then list the posts that are with that taxonomy. Code:               <?php $taxos = get_categories( 'taxonomy='.$taxonomy.'&post_type='.$type.'&orderby=term_group' ); ?>     <?php if($taxos) : foreach($taxos as $taxoOnglet) : ?>          <?php         $ongletQuery = new WP_Query(array(             'post_type' => $type,             $taxonomy => $taxoOnglet->slug,             'showposts' => -1,             'orderby'   => 'menu_order',             'order'     => 'ASC',         ));     ?>          [...]loop for showing the posts[...]          <?php endif; ?>     <?php wp_reset_query(); ?>      I do get all my posts with that query fine, but there is a problem. The parent taxonomies list their children's posts, even if the post is only attributed to the children. Which gives me something like this               PARENT TAXONOMY     Post A     Post B          CHILD A     Post A          CHILD B     Post B      So I'm trying to find a way to remove the A and B posts from the parent taxonomy, so they will only appear in the child where they are attributed. Is there a way to do this with the WP_Query of WP?


Get a list of commas separated categories inside a loop

I want to get the list of categories of a post inside the loop. Normally, I would use               the_category(', ');      But this does output a link, and I only want the category name. Any ideas?


Issues with downloading a file with wp_remote_get()

I'm using wp_remote_get() to download a remote file with the following URL:               http://feeds.paidonresults.net/1.0?affiliateid=34069&feedid=M742&template=CSV&CSVSeperator=comma&field_names=ProductID,ProductName,ProductPrice,SummaryDescription,ProductDescription,AffiliateURL,ImageURL100by100,ImageURL200by200,ProductAddedDate,Category,MerchantName      Using http://web-sniffer.net/ the headers are as follows: Connect to 80.249.99.4 on port 80 ... ok               GET /1.0?affiliateid=34069&feedid=M742&template=CSV&CSVSeperator=comma&field_names=ProductID%2CProductName%2CProductPrice%2CSummaryDescription%2CProductDescription%2CAffiliateURL%2CImageURL100by100%2CImageURL200by200%2CProductAddedDate%2CCategory%2CMerchantName HTTP/1.1[CRLF]     Host: feeds.paidonresults.net[CRLF]     Connection: close[CRLF]     User-Agent: Web-sniffer/1.0.37 (+http://web-sniffer.net/)[CRLF]     Accept-Encoding: gzip[CRLF]     Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7[CRLF]     Cache-Control: no-cache[CRLF]     Accept-Language: de,en;q=0.7,en-us;q=0.3[CRLF]     Referer: http://web-sniffer.net/[CRLF]     [CRLF]      Which is great. However, using wp_remote_get() I am receiving the following:               Array     (     [headers] => Array         (             [date] => Mon, 07 May 2012 19:12:56 GMT             [server] => Apache/2.2.22 (Unix)             [p3p] => policyref="http://www.paidonresults.com/w3c/p3p.xml",CP="CAO DSP COR LAW DEVa TAIa OUR BUS UNI ADMa CURa PHY ONL PUR COM NAV DEM STA"             [connection] => close             [content-type] => text/html         )          [body] => Fatal Error      [response] => Array         (             [code] => 200             [message] => OK         )          [cookies] => Array         (         )          [filename] =>      )      I know there is an issue with a wp_remote_get() and a remote redirect, but I've used file_get_contents() and the purpose built function here but I'm still getting the same body fatal error response Does anybody know a way around this?


Download images from media library to computer in BULK?

All I want is to download all images from the media library to my computer. I don't want to then use them in another site. I uploaded them from a camera card while traveling, and then it was stolen. These are now the only copies, and I would like them on my computer now that I'm home. I don't know how to use PHP very well. What seems like the most logical solution is for there to be an option under BULK ACTIONS to "Download." The only option currently listed is to "Delete Permanently." I feel like downloading a site's media content is an option that should have been made available from the start of WP. Can I get it with FTP? From what I read WP doesn't allow FTP. Can someone give me a simple guide to utilizing a PHP script to collect the files?


Relationship between two taxonomies and a custom post type

for a project, I've a CPT products with two taxonomies : category and brand. I would like to build a navigation from a category to a product under a brand.   * page 1 : list the categories terms   * page 2 : list the brand term having the selected category term   * page 3 : list the products under the brand and the category   * page 4 : display the product Obviously, page 1 and 4 are easy to do but i can't figure out how to retrieve the terms in the page 2 and the products in the page 3. I'm sure there is a way to do that. Any idea ? Thanks. Cyril **UPDATE 1** I have found a way to display the correct brands under the page 2 :               <?php     $term = get_term_by('slug',get_query_var('term'),'product_category');          $q1 = "         SELECT DISTINCT p1.ID         FROM             $wpdb->posts p1             INNER JOIN $wpdb->term_relationships tr1 ON (p1.ID = tr1.object_id)             INNER JOIN $wpdb->term_taxonomy tt1 ON (tr1.term_taxonomy_id = tt1.term_taxonomy_id)         WHERE tt1.term_id = '$term->term_id'         ";          $q2 = "         SELECT tt2.term_id         FROM             $wpdb->posts p2             INNER JOIN $wpdb->term_relationships tr2 ON (p2.ID = tr2.object_id)             INNER JOIN $wpdb->term_taxonomy tt2 ON (tr2.term_taxonomy_id = tt2.term_taxonomy_id)         WHERE p2.ID IN ($q1)         ";          $q3 = "         SELECT tt3.*         FROM             $wpdb->posts p3             INNER JOIN $wpdb->term_relationships tr3 ON (p3.ID = tr3.object_id)             INNER JOIN $wpdb->term_taxonomy tt3 ON (tr3.term_taxonomy_id = tt3.term_taxonomy_id)             INNER JOIN $wpdb->terms t3 ON t3.term_id = tt3.term_id         WHERE 1=1             AND tt3.term_id IN ($q2)             AND tt3.taxonomy = 'product_brand'         ORDER BY t3.name ASC         ";          $brands = $wpdb->get_results($q3);     ?>      I now need to know the category chosen in the taxonomy-brand.php file, any suggestion ? **UPDATE 2** Thanks to this thread : Custom post type taxonomies URL rewrite, I now have the correct navigation from the homepage to a product page. Just need to filter the results in the brand page.


how to redirect to a custom password retrieval page

I have a new site and I'm using bbpress beta-3 with it, I've created custom login/register/lost-password pages with the custom templates supplied with bbpress and I can't seem to find the filter/hook/action that "hijacks" the calls to `wp-login.php`. My biggest problem is with the `lost-password` page, I want to redirect with a notice, I can catch the error but I can't catch the `sent password` event. I'm now using in function.php:               function get_password_retrieve_errors(){         wp_redirect( site_url('lost-password').'?getpass=failed'  );     }          add_filter('lostpassword_redirect', 'get_password_retrieve_errors', 1);      and in form-user-lost-pass.php:               <?php if ( $_GET['getpass'] == 'failed' ) { ?>

Invalid username or e-mail, please try again.

     <?php } ?>        1. Is there a way to do it?   2. Is there a global $error object which I can always refer to?   3. Is there a global $notifications object I can always refer to? Thanks!


Remove international characters from slug - Almost done - Bit help

I want to remove some characters from the slug, like "¿" that we use in spanish for opening a question. If I go to wp-includes/formatting.php and in               function sanitize_title_with_dashes($title)      line 820 wp32 I add this               $title = str_replace('¿', '', $title);      just before $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); And it is working correctly. So when I write in the title "¿Qué tal?" the slug is "que-tal" Now, how to do it with a function so I can use it via functions.php or via a plugin?? I am doing this but it is not working               function limpiar_slug($slug)     {         $slug = str_replace('¿', '', $slug);         return $slug;     }          add_filter('sanitize_title_with_dashes', 'limpiar_slug');      Any suggestion??? Thanks in advance


How do I remove UL on wp_nav_menu?

I search on this site and found many answers for this question. Most of them is not working on my theme. Here is a one solution I found and it's working according to my need.               function wp_nav_menu_no_ul()     {         $options = array(             'echo' => false,             'container' => false,             'theme_location' => 'primary'         );              $menu = wp_nav_menu($options);         echo preg_replace(array(             '#^
]*>#',             '#
$#'         ), '', $menu);          }      This code will remove `ul` at beginning and the end of `wp_nav_menu()`. So in my theme I just write
     <?php  wp_nav_menu_no_ul(); ?>
      But the problem is coming again when I do not add or activate any menu via admin. `http://domain.com/wp-admin/nav-menus.php` Question : How do I remove the `<div><ul>**</ul></div>` whether the menu is active or not. Let me know * * * Finally I got it worked :) `functions.php`               function wp_nav_menu_no_ul()     {         $options = array(             'echo' => false,             'container' => false,             'theme_location' => 'primary',             'fallback_cb'=> 'default_page_menu'         );              $menu = wp_nav_menu($options);         echo preg_replace(array(             '#^
]*>#',             '#
$#'         ), '', $menu);          }          function default_page_menu() {        wp_list_pages('title_li=');     }       `header.php`
     <?php  wp_nav_menu_no_ul(); ?>


How to make WordPress use new Upload Path settings in Multisite Setup

I have a site that is setup for WordPress multisite. The main site works, but the subdomains are not functioning as I would like them to. Here are the settings for the main site: Upload Path: media/images/national Upload URL Path: http:// images.mydomain.com/national Fileupload Url: http:// www.mydomain.com/media/images/national These settings work, and I am able to upload images to the specified folder. However, when I try to use similar settings for any of the subdomains, WordPress ignores my settings and use its default settings, which are: Upload Path: wp-content/blogs.dir/4/files Upload URL Path: (blank) Fileupload URL: http:// cityname.mydomain.com/files I want all of my media files to go to my media folder and not the wp- content/blogs.dir folder. How can I get WordPress to use the settings I place in Upload Path, Upload Url Path and Fileupload Url instead of it defaulting to it's own settings? Final note: this also happens on a fresh install.


"The Events Calendar" Issues in WP 3.2

After updating to Wordpress 3.2, the show/hide functionality of the event authoring area on "The Events Calendar" is backwards - when the "All Day Event?" checkbox is checked, the time boxes appear. When it is unchecked, the time boxes disappear. This is _opposite_ behavior of what should happen. I suspect it's a Jquery issue. Has anyone else discovered this issue? ![All day event unchecked](http://i.stack.imgur.com/8XOu5.png) ![All day event checked](http://i.stack.imgur.com/MgZ4f.png)


Custom Post Type with Input fields to seperate table on database.

At the moment I'm using a custom post type called 'locations' I would like to be able to put input fields into the custom post type that would store the information such as ( address, type, phone number, etc.. ) in a separate table called 'markers' So when a new post is made it will create a new entry in the table markers from the following input fields / have it updatable or removable when post is either changed or deleted. I'm not sure where to start to get these linked together to work in such a fashion, I know how to make a insert.php file to add new locations and to create a database but not with wordpress in such a fashion. My apologies but I'm pretty new to SQL and PHP.


Selecting all posts from the children of a particular parent taxonomy

I've created a custom post type (minerals) with a custom taxonomy (location) which supports hierarchies. What I am trying to do is create a return according to the parent location of the mineral post type. > For example, someone clicks on Europe, and the results show all minerals > from all listed countries in Europe. Now the custom location taxonomy is organized to have all countries nested under their respective continent, but only the country (NOT the continent) is selected for the post. So my challenge is to sort through all the existing children of the requested parent and return the posts that met that criteria. (I've got a couple of other custom meta parameters to check as well, but those are easily filtered once I get this figured out.) To perform this selection, I'm using the $wpdb class at the beginning of template page. I've already done something similar for other taxonomies that were based on price and size for the same "mineral" custom post type, but this is a little more complex. Here's what I seem to need to do first:               SELECT wp_term_taxonomy.term_taxonomy_id      WHERE wp_term_taxonomy.parent = $continent_id      AND wp_term_taxnomy.count > 0;      I will assign these to a numeric array,then I would loop through the same query again to check if any of the selected `term_taxonomy_id` are assigned as `wp_term_taxonomy.parent` for other terms. In the end what I'll have is an array of term_taxonomy_id's by which to query the wp_term_relationships table. My question is this, how do I use this generated array in a MYSQL query. This is what I have so far:               SELECT wp_posts . *     FROM wp_posts, wp_term_relationships     WHERE wp_posts.ID = wp_term_relationships.object_id     AND wp_term_relationships.term_taxonomy_id = (SOMETHING FROM THE TERM TAX ARRAY OF IDS)     AND wp_posts.post_type = 'mineral'       This second line from the bottom is where I'm stuck. Maybe I'm doing this all wrong and someone can suggest a different approach. Thanks, Brent


Combine 2 different custom post slugs into a single permalink?

Need some help with this URL rewrite. I have 2 custom posts set up, 'company' and 'job'. I have a single-company page, and a single-job page, which work fine. A company can have many jobs, and I'm managing the relation between jobs and company using post meta. Single company URL is `http://..../company/abc-intl`, and single job url is `http://..../job/photoshop-designer`. I want a single job URL to include the slug of the company it belongs to/is related with. So for above example, it should be `http://..../company/abc- intl/job/photoshop-designer`. I tried a lot with 'add_rewrite_rule', 'add_rewrite_tag', but didn't seem to work. Please any ideas on how to achieve this URL?


Hide directly viewing content for custom post type

I'm using a lot of custom post types for creating sidebars, footers, etc and would like to hide direct viewing of these post types. Is this possible?


Custom search results page not showing excerpt

I have a custom content-searchresults.php page. However for some reason its not showing the excerpt, but other amends I make this on this are pulled through so it is using this template. Below is my code.               <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                       <?php if ( has_post_thumbnail() && ! post_password_required() && !is_single() ) : ?>                           <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                     <?php the_post_thumbnail('full', array('class' => 'img-responsive'));   ?>                                        <?php endif; ?>
                                      <?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && CrippsTheme_categorized_blog() ) : ?>
                         <?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'CrippsTheme' ) ); ?>
                     <?php                         endif;                              if ( is_single() ) :                             the_title( '
', '
' );                         else :                             the_title( '
', '
' );                         endif;                     ?>

             <?php the_excerpt(); ?>

         <a class="read-more" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >             Read more


Custom post type change excerpt more and excerpt length

I have written a some code to get custom `excerpt_length` and `excerpt_more`. The excerpt_length is working for both custom post type and general post. But I don't know why `excerpt_more` is not working for custom post types. Below is my code.               class Excerpt {            // Default length (by WordPress)       public static $length = 55;            // So you can call: doctoplus_excerpt('short');       public static $types = array(           'ten'=>10,           'few' => 15,           'short' => 25,           'regular' => 55,           'long' => 100         );       //Default more       public static $more = '...';            //So you can call doctoplus_excerpt('short','Read More');       public static $moreTypes = array(         1 => 'Read More',         2 => 'More',         3 => 'View more'       );       /**        * Sets the length for the excerpt,        * then it adds the WP filter        * And automatically calls the_excerpt();        *        * @param string $new_length         * @return void        * @author Girija        */       public static function length($new_length = 55) {         Excerpt::$length = $new_length;              add_filter('excerpt_length', 'Excerpt::new_length', 999);              Excerpt::output();       }            // Tells WP the new length       public static function new_length() {         if( isset(Excerpt::$types[Excerpt::$length]) )           return Excerpt::$types[Excerpt::$length];         else           return Excerpt::$length;       }            public static function more($new_more = 'Read More') {         Excerpt::$more = $new_more;         add_filter('excerpt_more', 'Excerpt::new_more', 999);       }            //Tell WP the custom more       public static function new_more() {         global $post;         if(isset(Excerpt::$moreTypes[Excerpt::$more]) ) {           return ' ID) . '">'. __(Excerpt::$moreTypes[Excerpt::$more], 'doctoplus') .'';         } else {           return Excerpt::$more;         }       }       // Echoes out the excerpt       public static function output() {         the_excerpt();       }          }          // An alias to the class     function doctoplus_excerpt($length = 55, $more = "...") {       Excerpt::length($length);       Excerpt::more($more);     }      Can any one help me? I really need this to be done. Thanks in advance.


Problem with adding values to 'post_updated_messages' filter

I'm having an issue with adding a filter to 'post_updated_messages' that I don't quite understand. I've written a function like so;               function acc_course_updated_messages( $messages ) {              $post             = get_post();         $post_type        = get_post_type( $post );         $post_type_object = get_post_type_object( $post_type );              $singular = 'Course';              $messages['course'] = array(                  0  => '', // Unused. Messages start at index 1.             1  => __( $singular . ' updated.', TEXTDOMAIN ),             2  => __( 'Custom field updated.', TEXTDOMAIN ),             3  => __( 'Custom field deleted.', TEXTDOMAIN ),             4  => __( $singular . ' updated.', TEXTDOMAIN ),                  /* translators: %s: date and time of the revision */             5  => isset( $_GET['revision'] ) ? sprintf( __( $singular . ' restored to revision from %s', TEXTDOMAIN ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,             6  => __( $singular . ' published.', TEXTDOMAIN ),             7  => __( $singular . ' saved.', TEXTDOMAIN ),             8  => __( $singular . ' submitted.', TEXTDOMAIN ),             9  => sprintf(                 __( $singular . ' scheduled for: %1$s.', TEXTDOMAIN ),                 // translators: Publish box date format, see http://php.net/date                 date_i18n( __( 'M j, Y @ G:i', TEXTDOMAIN ), strtotime( $post->post_date ) )             ),             10 => __( $singular . ' draft updated.', TEXTDOMAIN ),         );              if ( $post_type_object->publicly_queryable ) {                  $permalink = get_permalink( $post->ID );                  $view_link = sprintf( ' %s', esc_url( $permalink ), __( 'View ' . $singular, TEXTDOMAIN ) );             $messages[ $post_type ][1] .= $view_link;             $messages[ $post_type ][6] .= $view_link;             $messages[ $post_type ][9] .= $view_link;                  $preview_permalink = add_query_arg( 'preview', 'true', $permalink );             $preview_link = sprintf( ' %s', esc_url( $preview_permalink ), __( 'Preview ' . $singular, TEXTDOMAIN ) );             $messages[ $post_type ][8]  .= $preview_link;             $messages[ $post_type ][10] .= $preview_link;              }              return $messages;          }     add_filter( 'post_updated_messages', 'acc_course_updated_messages' );      I have two of these functions in two separate files – named differently. Most of it works fine, apart from when we get to adding $view_link to the $messages array. If I stick with the value of $messages[ $post_type ][x], the value is concatenated with the previous post type's $messages[ $post_type ][x] value. So I end up with;               View Courses View Profiles      As well as a few undefined index and undefined offset errors. However, if I change the value in each file to;               $messages['the_name_of_the_post_type'][x]      Everything works fine. I feel that it's something to do with scope but echoing out the value of $post_type gives the correct post type. Any ideas?


wp_editor with image upload

I would like to have a wordpress text editor on my site where users can add post and add images to the post. I'm using wp_editor in the code below. If I'm logged in as the admin and go to the live site I can see the text box and the media upload button but I don't have the usual text buttons above the text box. If I log out of WP and go to the page I don't have a media upload button. How do I include the text buttons above the text editor? How do I inclide the Media Uplaod button so users can add images to posts?                   <?php                  if(isset($_POST['new_post']) == '1'){                      $post_title = $_POST['post_title'];                 $post_category = $_POST['cat'];                 $post_content = $_POST['theText'];                      $new_post = array(                     'ID' => '',                     'post_author' => $user->ID,                     'post_category' => array($post_category),                     'post_content' => $post_content,                     'post_title' => $post_title,                     'post_status' => 'publish'                 );                      $post_id = wp_insert_post($new_post);                 $post = get_post($post_id);                 wp_redirect($post->guid);                  }              ?>              <form method='post' action="" class="idea_form">             Idea Title             <input type="text" name="post_title" id="title">             Idea                  <?php                      $content ='Submit Idea';                      $editor_id = 'myEditor';                      $settings = array(                     'teeny' => true,                     'quicktags' => true,                     'tinymce' => true,                     'media_buttons' => true,                     'wpautop' => true,                     'textarea_name' => 'theText',                     'editor_class' => 'my_TextBox',                     'drag_drop_upload' => true                 );                      wp_editor($content, $editor, $settings);                  ?>                  Category             <?php wp_dropdown_categories('orderby=name&hide_empty=0&exclude=1&hierarchical=1'); ?>             <input type="hidden" name="new_post" value="1">             <input type="submit" value="submit Idea" class="submit">         </form>


How to add videos on my home page slider?

How would you recommend adding videos to my website's home page slideshow, here is the php code that creates the slideshow:               <?php global $gpp; ?>

     <?php      $slides = array('gpp_slideshow_image_1','gpp_slideshow_image_2','gpp_slideshow_image_3');      $i=0;         foreach ($slides as $slide) {             if($gpp[$slide]<>"") {                 echo '

',"\n";             }         }     ?>


Recommendation for a Dynamic Table Plugin

Can anyone recommend plugin that I can use to add a table to a page? I've seen ones that use static data-- you hardcode the figures in the table. I want to pull the data from a custom db table and put it in a table. I looked at WP Table Reloaded, but I'm not sure whether, it's possible to use it with dynamic data. Any suggestions? Thank you.


get_post_meta no longer working

I am trying to use get_post_meta to return a value from the post meta, it was working completely fine then suddenly stopped working. I've tried and checked everything and i cannot seem to get it working again - the code i'm using is as below - no matter what i do, i cannot return the meta value for the meta field any more. The code is added to functions.php. It literally just stopped working, it was previously pulling in the correct data now i cannot pull in any meta data whatsoever.               function latest()   {     $args = array( 'posts_per_page' => 1);                       $last_5_posts_query = new WP_Query( $args );     while($last_5_posts_query->have_posts()) :          $last_5_posts_query->the_post();         $link = get_permalink();         $title = get_the_title();           $title1 = get_post_meta(get_the_ID(), 'Title 1', true);              $title2 = get_post_meta(get_the_ID(), 'Title 2', true);           $more = 'Read more...';                  $content .= '
';         $content .= '
'  .$title1.  '
';         $content .= '
'  .$title2.  '
';         $content .= '
';     endwhile;          return $content;     }      Any ideas? The meat names "Title 1" and "Title 2" still exist. Completely out of ideas.


Multisite - Retrieve the same theme option from all sites of the network

I'm running multisite with each subsite using the same custom theme. I'm using NHP Options for logo upload and contact page info changes in that theme. I'd like to add a site list page to the main site (which is using a different theme) and have each subsites logo be displayed beside its name in the list. Getting the site list was fine - no problems there, but for the life of me I can't figure out how to get the logos to show. The data is stored in a serialized array in each sites options table - with the option_name of 'nhp_opts'. The data looks like this :                   a:5:{s:8:"last_tab";s:1:"0";i:19;s:59:"http://_PATH_TO_LOGO.png";i:20;         s:34:"Test Street,Testing,Co. Test";i:21;s:16:"(000) 123 456789";s:10:"multi_text";         a:4:{i:0;s:21:"Mon - Fri 9.30 - 6.00";i:1;s:18:"Sat - 10.00 - 6.00";         i:2;s:18:"Sun - 12.00 - 5.00";i:3;s:22:"Bank Holidays - Closed";}}      and the code I cobbled together is this:                   <?php global $wpdb;                 $logos = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->options WHERE option_name = nhp_opts  "));                     foreach($logos as $logo){                     $thedata = $logos;                     $thedata = unserialize($thedata);                     echo $thedata;                          }?>      All I get is Array() - repeated a bunch of times. I'm not very familiar with working directly with the database - so I'm not overly surprised this didn't work! I've spent a few days now puzzling this one out - any help at all would be greatly appreciated! Thanks!


finding menu hierachy > wp_get_nav_menu_items

Hi I am building a menu using the code listed here. http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items Is there a way to suss out the menu hierarchy. As i can not debug this, it is difficult for me to see what wp_get_nav_menu_items actually returns.               $menu_items = wp_get_nav_menu_items($menu->term_id);       or               <?php $items = wp_get_nav_menu_items($menu, $args = array()); ?>       Is there a listing that describes the objects returned via wordpress functions? Any help much appreciated.


the_excerpt Read More Filter

Currently, I call the_excerpt via traditional means:               <?php the_excerpt(); ?>      But I add a filter in functions.php for a custom "read more" message.               // Changing excerpt more     function new_excerpt_more($post) {         return ' ID) . '">' . 'read more' . '';     }     add_filter('excerpt_more', 'new_excerpt_more');       Here's the problem; I would like to call the_excerpt inside posts as well without any read more type of link being displayed while leaving the_exerpt being used in the actual excerpts unimpacted.


Customize category query in widget

I would like to exclude a category from my categories sidebar widget. If I understand the way this works, the sidebar.php code is not in use since the widget is displaying the categories. (something similar was discussed in this support topic: http://wordpress.org/support/topic/problem-trying-to-hide-a- category-in-the-sidebar ). How can I modify the query used by the widget; or is there another means of excluding specific categories from inclusion in the category list?


How to set different cookies for logged in admin users and logged in non admin users?

I would like to identify admin users and non-admin (but logged in) users through cookies. I need this feature because I use Hyper Cache (which uses cookies to identify those who send pages in cache): I would like to serve cached page to all users not logged in and to all users logged in but non- admin. The logged in admin users will not get cached pages.


problems exluding categories

I have done this before but for some reason, it is not working and I can't figure out why. All I am trying to do is exclude some categories from the blog page. I thought this would be a simple matter. I have the index.php file open, and before my loop, I did this                query_posts( $guery_string . '&cat=-6' )      if (have_posts)......rest of loop here.      I have even tried adding the global $query_string; on top but nothing I do will get rid of category 6. Does this method no longer work in the latest version of wordpress?


Convert comments to Custom Post Type

Currently, I use WordPress as a Q&A website where users can register, ask questions and give answers as well. I use the AskIt theme from ElegantThemes which uses the default WordPress Post Types (Posts, Pages, Comments, etc.). There are about 300 registered users, more than 350 questions and 1000 answers/comments right now. The new theme I want to migrate to (ForumEngine), adds/uses Custom Post Types for the Questions (instead of the current Posts) and Answers (instead of the current comments). Also, the 'blog' section, which co-exists with Custom Post Types, use the default WP Post types (Posts, comments). I managed to convert the default Post type to Custom Post Type (Questions) with the help of a plugin. My problem is that I don't know how can I convert the comments to the Custom Post Type (Answers) and since the fact that comments are not Post Types apparently this one might be tricky. When I go to the Edit page of a converted CPT post, I can see the comments at the bottom but they are not showing in the frontend. So, they are still linked to each post but couldn't figure out how to convert them to the CPT. Can you please help me figure out how can I do this? _I already did a further research and asked theme's creators for help but this is beyond their scope of support._


Can WordPress Plugin Directory Cache Delay the Upload of Images?

I've updated my plugin and I can see the updated text on the plugin page but I don't see any of the screenshots or header image. Is it possible that the cache will move the image files over later? Or did I do something syntactically wrong so they are not showing up? FYI I did run my readme file through the WordPress readme file validator.


How can I safely override contact form 7 styles?

Where do I place css styles to override the default styles of contact form 7 so that my changes do not get overwritten whenever I update this plugin?


How to use taxonomy term as permalink folder

I've searched around and haven't found a way to do this yet. I'm trying to create a custom post type that will display a permalink structure that uses the term of a taxonomy as the folder name. Here's an example of what I'm trying to accomplish. ## custom taxonomy `page_type`   Example terms:   * article   * video ## custom post type `custom_page`   Example pages:   * carpentry   * quality drywall   * concrete work ## Desired permalink structure   * http://site.com/%page_type%/%custom_page%   * http://site.com/video/quality-drywall Perhaps this isn't possible.


How do I prevent Plugin updates from clobbering user edits?

How can I prevent my plugin updates from clobbering the user edits and file additions in a particular subdirectory of my plugin? I wrote a syntax highlighting plugin that makes use of GeSHi. A sub folder of the plugin is GeSHi itself. Many users will want to customize / edit the language files within GeSHi. Specifically here is the directory structure:   * wp-contente/plugins/my-plugin/      * several subdirectories etc   * wp-content/plugins/my-plugin/geshi/geshi/      * users are going to add files to this directory     * they will also edit files in this directory     * when they pick up their new updates I don't want to erase their edits What's the best way of solving this? Thanks! * * * Here's what I was thinking, but I don't know how to implement:   1. On the update plugin action hook (?) make a temporary copy of the files I want to preserve.   2. Get the new version unzip and install like usual   3. Copy the preserved files from the temp copy to the new version   4. Remove the temp copy Ideally this would all be done with files, but worst case scenario I could save data to the DB. Problem is I don't see hooks for plugin updates. I looked here and here.


Is there a maximum number of author for a blog?

I am building a WP blog which will feature the work of many artists and I would like to show, for each post, the artist bio. Since it is possible for an artist to have many posts over time on the blog, I don't want to insert the bio info directly inside the post and instead use a custom function to show it. This is why I was thinking about using the author meta data to store the info about the artist. Doing this brings 2 questions:   1. is there a hard limit to the number of authors (or reason not have a lot of authors)   2. is there a reason not to do it this way? (or a better way to do it)


Log Author Actions

Is there a place where actions like post creation/deletion, page creation/deletion, modification, etc. is saved? Is this stored in the Apache logs? If this is not saved, is there a way (plugin?) to do this?


Is there a plugin that will facilitate displaying a website (static pages, not a blog) content in two languages

I am looking for the easiest way to display the content of a single website in two different languages, do not need translation, I do have my own translation. I just want to display the same pages, but in one set in English and the other in Spanish. Could anyone guide me on how to achieve it? Is there a plugin that will allow me to just retype the content and use the same pictures, layout, etc.??


How to force "remember me" users to login again?

My question is how to force the users that are auto-logged in because they previously checked "remember me" to log in again? It may be something with cookies, but is there anything I can change/modify to do this ? Thank you. **UPDATE** Generally, using jQuery cookie plugin, the code that checks for a cookie in user's system looks like this.               $(document).ready(function(){     if(!$.cookie('name-of-cookie')){         $.cookie('name-of-cookie', 'true', { expires: 2});     .     .     }      Is there any similar in Wordpress to handle this?


WP admin bar disappeared

The admin bar suddenly disappeared from the front end side of my site. It is present and works alright at the backend. I thought it could be due to some plugin so I deactivated them one by one and checked . Now all the plugins are deactivated and the admin bar is still missing...My theme does have the `wp_footer()` in footer.php. What is it that I am missing?


Manually installed plugin doesn't show up

I installed a plugin called hide-title by unzipping it and copying the files to the plugins dir. But it doesn't show up in the plugin list. I've checked the following:   * the plugin's main php file looks fine at a glance, it has the required header   * there's no double nesting problem such as "plugins/hide-title/hide-title/..."   * I've tried chmod -R 777 wp-content   * The plugin is compatible with my wordpress version   * I'm not working in a wrong dir - I tried, for example, renaming the twentyten theme to twentyten_ and that got reflected in the dashboard It seems to be a more general problem because I also tried installing a theme and got the same problem. I don't want to install the stuff via the dashboard UI because I had FTP/permissions problems with that and gave up on it.


shortcode - I need to throw a message or load a different page

I am displaying a form on the public side using shortcode.The shortcode is included on Post add_new, located at `http://localhost/wordpress/add_new/`. On successful saving of form data, I need the page to either 1) change the page's location and show a message of successful completion, or show a message of successful completion on page add_new. This is my shortcode:               add_shortcode( 'show_INT_form', function() {         $int_class = new int_class;              if ( isset( $_REQUEST['int_prefix'] ) && isset( $_REQUEST['int_suffix'] ) ) {              // ???? Area X             // What do I do here?             // ????         }         else {             $ret = $int_class->public_form(); // function that loads the form onto the page         }              return $ret;     } );      How can I have the add_new page load another page? I have seen sample code simply echoing `<meta http-equiv='refresh' content='0;url=page_to_load' />` in **Area X** located in the comments in the code above. I have tried this, and it works, but is this proper procedure? I have not tried other methods since I don't know how to work around the function and class scope. How could I call a new event listener (such as `add_action( 'send_headers' )` ) outside of my add_shortcode function and pass it an argument, such as a 'success' or 'error' message?


how to make stylesheet appear in theme editor?

I have a stylesheet in my theme in the css subdir of the theme dir (`css/style.css`). The question is how to make this .css file appear in the theme editor of the WordPress admin. (I know using the web editor is a bad idea and I never use it, but the client specifically asked for this). Note: the only css file that shows up by default in my theme editor is 'style.css' of the root theme dir, but this is not what I need.


Search doesn't work with 'relation' => 'OR'

**Records in the Database:** 5 **The Problem:** This code takes long to search 5 records and hangs up after with no success results. If I change the `'relation' => 'OR'` to `'relation' => 'AND'` it works but that's not what am looking for in this scenario. **_Is everything okay in my code?_**               <?php     $args = array(         'post_type' => 'shipping-schedules',          'posts_per_page' => 5,         'post_status' => 'publish',         'paged' => $paged,         'meta_query' => array(         'relation' => 'OR',             array(                 'key' => 'schedules_port',                 'value' => $sfrom,                 'compare' => 'LIKE'             ),             array(                 'key' => 'schedules_port',                 'value' => $sto,                 'compare' => 'LIKE'             ),             array(                 'key' => 'schedules_vessel',                 'value' => $svessel,                 'compare' => 'LIKE'             ),             array(                 'key' => 'schedules_voyage',                 'value' => $svoyage,                 'compare' => 'LIKE'             ),             array(                 'key' => 'schedules_arrival',                 'value' => $sdate_arrival,                 'compare' => '>=',                 'type' => 'NUMERIC'             ),             array(                 'key' => 'schedules_departure',                 'value' => $sdate_departure,                 'compare' => '<=',                 'type' => 'NUMERIC'             )         )     );                                   ?>


the_widget() inside functions.php

I'm setting some options in the backend using functions.php and I'm doing:               $w = the_widget('My_Custom_Widget');      but I don't get any output. However doing               <?php the_widget('My_Custom_Widget'); ?>      on any page template works fine. How can I do this?


Sitewide Tags and Transient API

I'm running a couple of multisite networks and am using a useful plugin called WordPress MU Sitewide Tags Pages. I like the plugin very much but I am concerned about performance, especially as my networks generate more simultaneous users and get larger in terms of number of subsites. I would like to use the Transients API to give the plugin some added performance, but despite my best research, I have not found any useful direction on where to start. I'm wondering if the plugin itself would need adjusting, or if the loop in my theme would need adjusting. I'm using a standard loop. Would it make more sense to cache this loop or cache a custom WP_Query variable? I know the plugin is over 500 lines long, but I thought it would be instructive start a conversation on how to best apply Transients API to the plugin. Here is the plugin:               <?php     /*     Plugin Name: WordPress MU Sitewide Tags Pages     Plugin URI: http://ocaoimh.ie/wordpress-mu-sitewide-tags/     Version: 0.4.2     Author: Donncha O Caoimh     Author URI: http://ocaoimh.ie/     */     /*  Copyright 2008 Donncha O Caoimh (http://ocaoimh.ie/)         With contributions by Ron Rennick(http://wpmututorials.com/), Thomas Schneider(http://www.im-web-gefunden.de/) and others.     */          function swt_add_pages() {         global $wpmu_version, $wp_version;         if ( version_compare( $wp_version, '3.0.9', '<=' ) && version_compare( $wp_version, '3.0', '>=' ) && is_multisite() && is_super_admin() ) {             add_submenu_page( 'ms-admin.php', 'Sitewide Tags', 'Sitewide Tags', 'manage_options', 'sitewidetags', 'swt_manager' );         } elseif ( isset( $wpmu_version ) && is_site_admin() ) {             add_submenu_page( 'wpmu-admin.php', 'Sitewide Tags', 'Sitewide Tags', 'manage_options', 'sitewidetags', 'swt_manager' );         }     }     add_action('admin_menu', 'swt_add_pages');          function swt_network_add_pages() {         add_submenu_page( 'settings.php', 'Sitewide Tags', 'Sitewide Tags', 'manage_options', 'sitewidetags', 'swt_manager' );     }     add_action('network_admin_menu', 'swt_network_add_pages');          function swt_text_domain() {         load_muplugin_textdomain( 'wpmu-sitewide-tags', MUPLUGINDIR . '/languages' );     }     add_action( 'init', 'swt_text_domain' );          function swt_manager() {         echo '
';         if( !empty( $_REQUEST['updated'] ) && '1' == $_REQUEST['updated'] )              echo '

' . __( 'Settings updated.', 'wpmu-mu-sitewide-tags' ) . '

';              echo '
' . __( 'Global Tags', 'wpmu-sitewide-tags' ) . '
';         echo '<form name="global_tags" action="" method="post">';         echo '<input type="hidden" name="action" value="sitewidetags" />';         wp_nonce_field('sitewidetags');         if( get_sitewide_tags_option( 'tags_blog_public' ) === null )             add_site_option( 'sitewide_tags_blog', array( 'tags_blog_public' => 1 ) );              $tags_blog_enable = get_sitewide_tags_option( 'tags_blog_enabled' );         ?>

                 <?php _e('Tags Blog','wpmu-sitewide-tags') ?>	                                       <input name="tags_blog_enabled" type="checkbox" id="tags_blog_enabled" value="1" <?php if( $tags_blog_enable == 1 ) { echo "checked='checked'"; } ?> /> <?php _e("Enabled","wpmu-sitewide-tags"); ?>
         <?php         if( !$tags_blog_enable ) {             echo "

<input class='button-primary' type='submit' value='" . __( 'Update Settings', 'wpmu-mu-sitewide-tags' ) . "' />
                 </form>
";             return false;         }         $tags_blog_public = get_sitewide_tags_option( 'tags_blog_public' );         $tags_blog_pages = get_sitewide_tags_option( 'tags_blog_pages' );         $tags_blog_thumbs = get_sitewide_tags_option( 'tags_blog_thumbs' );         $tags_blog_pub_check = get_sitewide_tags_option( 'tags_blog_pub_check' );         $tags_blog_postmeta = get_sitewide_tags_option( 'tags_blog_postmeta' );         ?>
<?php _e( "You can create your post archive in a specific 'tags' blog of your choosing, or you can use the main blog of your site. Each has it's own pros and cons.","wpmu-sitewide-tags"); ?>

<input name="tags_blog" type="text" id="tags_blog" style="width: 35%" value="<?php echo esc_attr( get_sitewide_tags_option( 'tags_blog', 'tags' ) ); ?>" size="45" />
         <?php _e('Blogname of the blog your global tags and posts will live in. Blog will be created.','wpmu-sitewide-tags') ?>

<input name="tags_blog_main_blog" type="checkbox" id="tags_blog_main_blog" value="1" <?php if( get_sitewide_tags_option( 'tags_blog_main_blog', 0 ) == 1 ) { echo "checked='checked'"; } ?> /> <?php _e( "Post to main blog","wpmu-sitewide-tags" ); ?>
         <?php _e('Create posts in your main blog. All posts will appear on the front page of your site. Remember to to add a post loop to home.php in the theme directory if it exists.','wpmu-sitewide-tags') ?>

                 <?php _e('Max Posts','wpmu-sitewide-tags') ?>	                                       <input name="tags_max_posts" type="text" id="tags_max_posts" style="width: 15%" value="<?php echo intval( get_sitewide_tags_option( 'tags_max_posts', 5000 ) ); ?>" size="5" />
                     <?php _e('The maximum number of posts stored in the tags blog.','wpmu-sitewide-tags') ?>

                 <?php _e('Include Pages','wpmu-sitewide-tags') ?>	                                       <input name="tags_blog_pages" type="checkbox" id="tags_blog_pages" value="1" <?php if( $tags_blog_pages == 1 ) { echo "checked='checked'"; } ?> /> <?php _e("Enabled","wpmu-sitewide-tags"); ?>

                 <?php _e('Include Post Thumbnails','wpmu-sitewide-tags') ?>	                                       <input name="tags_blog_thumbs" type="checkbox" id="tags_blog_thumbs" value="1" <?php if( $tags_blog_thumbs == 1 ) { echo "checked='checked'"; } ?> /> <?php _e("Enabled","wpmu-sitewide-tags"); ?>

                 <?php _e('Privacy','wpmu-sitewide-tags') ?>	                                       <input type='radio' name='tags_blog_public' value='1' <?php echo ( $tags_blog_public == 1 ? 'checked="checked"' : '' ) ?> /> <?php _e('Tags pages can be indexed by search engines.','wpmu-sitewide-tags')?>
                     <input type='radio' name='tags_blog_public' value='0' <?php echo ( $tags_blog_public == 0 ? 'checked="checked"' : '' ) ?> /> <?php _e('Tags pages will not be indexed by search engines.','wpmu-sitewide-tags')?>
                     <?php _e('Will your tags pages be visible to Google and other search engines?','wpmu-sitewide-tags');             if( $tags_blog_public == 1 ) { ?>                     <input name="tags_blog_pub_check" type="hidden" value="0" />      <?php } else { ?>

                 <?php _e('Non-Public Blogs','wpmu-sitewide-tags') ?>	                                       <input name="tags_blog_pub_check" type="checkbox" id="tags_blog_pub_check" value="1" <?php if( $tags_blog_pub_check == 1 ) { echo "checked='checked'"; } ?> /> <?php _e("Enabled","wpmu-sitewide-tags"); ?>
                     <?php _e('Include posts from blogs not indexed by search engines.','wpmu-sitewide-tags');              } ?>
                      <?php _e('Post Meta') ?>	                                               <textarea name="tags_blog_postmeta" id="tags_blog_postmeta" cols='40' rows='5'><?php echo $tags_blog_postmeta == '' ? '' : @implode( "\n", $tags_blog_postmeta ); ?></textarea>
                         <?php _e('If you want to copy custom fields with posts. One custom field per line.') ?>

<input class='button-primary' type='submit' value='<?php _e( 'Update Settings', 'wpmu-mu-sitewide-tags' ) ?>' />
         </form>         <?php         echo '<form name="global_tags" action="" method="GET">';         echo "<input type='hidden' name='page' value='sitewidetags' />";         echo "<input type='hidden' name='action' value='populateblogs' />";         wp_nonce_field('sitewidetags');         ?>

                 <?php _e('Populate Posts','wpmu-sitewide-tags') ?>	                                       <?php printf( __( 'Blog ID: %s OR', 'wpmu-sitewide-tags' ), '<input name="populate_blog" type="text" id="populate_blog" style="width: 15%" value="" size="5" />' ); ?>
                     <input name="populate_all_blogs" type="checkbox" id="populate_all_blogs" value="1" /> <?php _e( 'All blogs', 'wpmu-sitewide-tags' ); ?>
                     <?php _e( 'Add posts from the blog named above or all blogs to the sitewide tags blog. This page will reload while copying the posts and may take a long time to finish.', 'wpmu-sitewide-tags' ) ?>
                     <?php _e( 'Note: Depending on your server resources, you may need to turn off other plugins while using the populate feature.', 'wpmu-sitewide-tags' ) ?>

<input class='button-primary' type='submit' value='<?php _e( 'Poplate Posts', 'wpmu-mu-sitewide-tags' ) ?>' />
         </form>
         <?php     }          function sitewide_tags_update_options() {         global $wpdb, $current_site, $current_user, $wp_version;              $valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'sitewidetags') : false;         if ( !$valid_nonce )             return false;              if ( $_GET[ 'action' ] == 'populateblogs' ) {             $id = isset( $_GET[ 'populate_blog' ] ) ? (int)$_GET[ 'populate_blog' ] : 0;             $c = isset( $_GET[ 'c' ] ) ? (int)$_GET[ 'c' ] : 0; // blog count             $p = isset( $_GET[ 'p' ] ) ? (int)$_GET[ 'p' ] : 0; // post count             $all = isset( $_GET[ 'all' ] ) ? (int)$_GET[ 'all' ] : 0; // all blogs                  if  ( $id == 0 && isset( $_GET[ 'populate_all_blogs' ] ) ) // all blogs.                 $all = 1;                  $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );             if( !$tags_blog_id )                 return false;                  if( $all )                 $blogs = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id DESC LIMIT %d,5", $c ) );             else                 $blogs = array( $id );                  foreach( $blogs as $blog ) {                 if( $blog != $tags_blog_id ) {                     $details = get_blog_details( $blog );                     $url = add_query_arg( array( 'p' => $p, 'action' => 'sitewidetags-populate', 'key' => md5( serialize( $details ) ) ), $details->siteurl );                     $p = 0;                     $post_count = 0;                          $result = wp_remote_get( $url );                     if( isset( $result['body'] ) )                         $post_count = (int)$result['body'];                          if( $post_count ) {                         $p = $post_count;                         break;                     }                 }                 $c++;             }             if( !empty( $blogs ) && ( $all || $p ) ) {                 if ( version_compare( $wp_version, '3.0.9', '<=' ) && version_compare( $wp_version, '3.0', '>=' ) )                     $url = admin_url( 'ms-admin.php' );                 else                     $url = network_admin_url( 'settings.php' );                      wp_redirect( wp_nonce_url( $url , 'sitewidetags' ) . "&page=sitewidetags&action=populateblogs&c=$c&p=$p&all=$all" );                 die();             }             wp_die( 'Finished importing posts into tags blogs!' );               }              if( !$_POST[ 'tags_blog_enabled' ] ) {             if( get_sitewide_tags_option( 'tags_blog_enabled' ) != $_POST[ 'tags_blog_enabled' ] )                  update_sitewide_tags_option( 'tags_blog_enabled', 0, true );             wp_redirect( add_query_arg( array( 'updated' => '1' ) ) );             exit;         }         update_sitewide_tags_option( 'tags_blog_enabled', 1 );              if( ( isset( $_POST[ 'tags_blog' ] ) || isset( $_POST[ 'tags_blog_main_blog' ] ) ) && isset( $_POST[ 'tags_blog_public' ] ) ) {             if( $_POST[ 'tags_blog_main_blog' ] == 1 ) {                 if( $current_site->blog_id )                     $id = $current_site->blog_id;                 else                     $id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain = '{$current_site->domain}' AND path = '{$current_site->path}'" );                 if( $id ) {                     update_sitewide_tags_option( 'tags_blog_id', $id );                     update_sitewide_tags_option( 'tags_blog_main_blog', 1 );                 } else {                     update_sitewide_tags_option( 'tags_blog_main_blog', 0 );                 }             } else {                 update_sitewide_tags_option( 'tags_blog_main_blog', 0 );                 $tags_blog = $_POST[ 'tags_blog' ];                 update_sitewide_tags_option( 'tags_blog', $tags_blog );                 if( constant( 'VHOST' ) == 'yes' ) {                     $domain = $tags_blog . '.' . $current_site->domain;                     $path = $current_site->path;                 } else {                     $domain = $current_site->domain;                     $path = trailingslashit( $current_site->path . $tags_blog );                 }                 $tags_blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain = '$domain' AND path = '$path'" );                 if( $tags_blog_id ) {                     update_sitewide_tags_option( 'tags_blog_id', $tags_blog_id );                 } else {                     $wpdb->hide_errors();                     $id = wpmu_create_blog( $domain, $path, __( 'Global Posts','wpmu-sitewide-tags' ), $current_user->id , array( "public" => $_POST[ 'tags_blog_public' ] ), $current_site->id);                     update_sitewide_tags_option( 'tags_blog_id', $id );                     $wpdb->show_errors();                 }             }             $tags_blog_public = (int)$_POST[ 'tags_blog_public' ];             update_sitewide_tags_option( 'tags_blog_public', $tags_blog_public );             update_blog_option( $tags_blog_id, 'blog_public', $tags_blog_public );             update_blog_status( $tags_blog_id, 'public', $tags_blog_public);         }              if( isset( $_POST[ 'tags_max_posts' ] ) )             update_sitewide_tags_option( 'tags_max_posts', (int)$_POST[ 'tags_max_posts' ] );              if( get_sitewide_tags_option( 'tags_blog_pages' ) != $_POST[ 'tags_blog_pages' ] )             update_sitewide_tags_option( 'tags_blog_pages', (int)$_POST[ 'tags_blog_pages' ] );              if( get_sitewide_tags_option( 'tags_blog_thumbs' ) != $_POST[ 'tags_blog_thumbs' ] )             update_sitewide_tags_option( 'tags_blog_thumbs', (int)$_POST[ 'tags_blog_thumbs' ] );              if( get_sitewide_tags_option( 'tags_blog_pub_check' ) != $_POST[ 'tags_blog_pub_check' ] ) {             if( $tags_blog_public == 0 )                 update_sitewide_tags_option( 'tags_blog_pub_check', (int)$_POST[ 'tags_blog_pub_check' ] );             else                 update_sitewide_tags_option( 'tags_blog_pub_check', 0 );         }              if( $_POST['tags_blog_postmeta'] != '' ) {             $meta_keys = split( "\n", stripslashes( $_POST[ 'tags_blog_postmeta' ] ) );             foreach( (array) $meta_keys as $key ) {                 $keys[] = trim( $key );             }             update_sitewide_tags_option( "tags_blog_postmeta", $keys );         } else {             update_sitewide_tags_option( "tags_blog_postmeta", '' );         }              // force write if changes saved         update_sitewide_tags_option( true );         wp_redirect( add_query_arg( array( 'updated' => '1' ) ) );         exit;     }     if ( !empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'sitewidetags' )         add_action( 'admin_init', 'sitewide_tags_update_options' );     /*     run populate function in local blog context because get_permalink does not produce the correct permalinks while switched     */     function sitewide_tags_populate_posts() {         global $wpdb;              $valid_key = isset( $_REQUEST['key'] ) ? $_REQUEST['key'] == md5( serialize( get_blog_details( $wpdb->blogid ) ) ) : false;         if ( !$valid_key )             return false;              $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         $tags_blog_enabled = get_sitewide_tags_option( 'tags_blog_enabled' );              if( !$tags_blog_enabled || !$tags_blog_id || $tags_blog_id == $wpdb->blogid )             exit( '0' );              $posts_done = 0;         $p = isset( $_GET[ 'p' ] ) ? (int)$_GET[ 'p' ] : 0; // post count         while ( $posts_done < 300 ) {             $posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' LIMIT %d, 50", $p + $posts_done ) );                  if ( empty( $posts ) )                  exit( '0' );                  foreach ( $posts as $post ) {                 if ( $post != 1 && $post != 2 )                     sitewide_tags_post( $post, get_post( $post ) );                  }             $posts_done += 50;         }         exit( $posts_done );     }     if ( !empty( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'sitewidetags-populate' )         add_action( 'init', 'sitewide_tags_populate_posts' );          function sitewide_tags_post( $post_id, $post ) {         global $wpdb;              if( !get_sitewide_tags_option( 'tags_blog_enabled' ) )             return;              // wp_insert_category()         include_once(ABSPATH . 'wp-admin/includes/admin.php');              $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         if( !$tags_blog_id || $wpdb->blogid == $tags_blog_id )             return;              $allowed_post_types = apply_filters( 'sitewide_tags_allowed_post_types', array( 'post' => true ) );         if ( !$allowed_post_types[$post->post_type] )              return;              $post_blog_id = $wpdb->blogid;         $blog_status = get_blog_status($post_blog_id, "public");         if ( $blog_status != 1 && ( $blog_status != 0 || get_sitewide_tags_option( 'tags_blog_public') == 1 || get_sitewide_tags_option( 'tags_blog_pub_check') == 0 ) )             return;              $post->post_category = wp_get_post_categories( $post_id );         $cats = array();         foreach( $post->post_category as $c ) {             $cat = get_category( $c );             $cats[] = array( 'name' => esc_html( $cat->name ), 'slug' => esc_html( $cat->slug ) );         }              $post->tags_input = implode( ', ', wp_get_post_tags( $post_id, array('fields' => 'names') ) );              $post->guid = $post_blog_id . '.' . $post_id;              $global_meta = array();         $global_meta['permalink'] = get_permalink( $post_id );         $global_meta['blogid'] = $org_blog_id = $wpdb->blogid; // org_blog_id              $meta_keys = apply_filters( 'sitewide_tags_meta_keys', get_sitewide_tags_option( 'tags_blog_postmeta', array() ) );         if( is_array( $meta_keys ) && !empty( $meta_keys ) ) {             foreach( $meta_keys as $key )                 $global_meta[$key] = get_post_meta( $post->ID, $key, true );         }         unset( $meta_keys );              if( get_sitewide_tags_option( 'tags_blog_thumbs' ) && ( $thumb_id = get_post_meta( $post->ID, '_thumbnail_id', true ) ) ) {             $thumb_size = apply_filters( 'sitewide_tags_thumb_size', 'thumbnail' );             $global_meta['thumbnail_html'] = wp_get_attachment_image( $thumb_id, $thumb_size );         }              // custom taxonomies          $taxonomies = apply_filters( 'sitewide_tags_custom_taxonomies', array() );         if( !empty( $taxonomies ) && $post->post_status == 'publish' ) {             $registered_tax = array_diff( get_taxonomies(), array( 'post_tag', 'category', 'link_category', 'nav_menu' ) );             $custom_tax = array_intersect( $taxonomies, $registered_tax );             $tax_input = array();             foreach( $custom_tax as $tax ) {                 $terms = wp_get_object_terms( $post_id, $tax, array( 'fields' => 'names' ) );                 if( empty( $terms ) )                     continue;                 if( is_taxonomy_hierarchical( $tax ) )                     $tax_input[$tax] = $terms;                 else                     $tax_input[$tax] = implode( ',', $terms );             }             if( !empty( $tax_input ) )                     $post->tax_input = $tax_input;         }              switch_to_blog( $tags_blog_id );         if( is_array( $cats ) && !empty( $cats ) && $post->post_status == 'publish' ) {             foreach( $cats as $t => $d ) {                 $term = get_term_by( 'slug', $d['slug'], 'category' );                 if( $term && $term->parent == 0 ) {                     $category_id[] = $term->term_id;                     continue;                 }                 /* Here is where we insert the category if necessary */                 wp_insert_category( array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => '') );                      /* Now get the category ID to be used for the post */                 $category_id[] = $wpdb->get_var( "SELECT term_id FROM " . $wpdb->get_blog_prefix( $tags_blog_id ) . "terms WHERE slug = '" . $d['slug'] . "'" );             }         }              $global_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE guid IN (%s,%s)", $post->guid, esc_url( $post->guid ) ) );         if( $post->post_status != 'publish' && is_object( $global_post ) ) {             wp_delete_post( $global_post->ID );         } else {             if( $global_post->ID != '' ) {                 $post->ID = $global_post->ID; // editing an old post                      foreach( array_keys( $global_meta ) as $key )                     delete_post_meta( $global_post->ID, $key );             } else {                 unset( $post->ID ); // new post             }         }         if( $post->post_status == 'publish' ) {             $post->ping_status = 'closed';             $post->comment_status = 'closed';                  /* Use the category ID in the post */                 $post->post_category = $category_id;                  $p = wp_insert_post( $post );             foreach( $global_meta as $key => $value )                 if( $value )                     add_post_meta( $p, $key, $value );         }         restore_current_blog();     }     add_action('save_post', 'sitewide_tags_post', 10, 2);          function sitewide_tags_post_delete( $post_id ) {         /*          * what should we do if a post will be deleted and the tags blog feature is disabled?          * need an check if we have a post on the tags blog and if so - delete this          */         global $wpdb;         $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         if( null === $tags_blog_id )             return;              if( $wpdb->blogid == $tags_blog_id )             return;              $post_blog_id = $wpdb->blogid;         switch_to_blog( $tags_blog_id );         $guid = "{$post_blog_id}.{$post_id}";         $global_post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid IN (%s,%s)", $guid, esc_url( $guid ) )  );         if( null !== $global_post_id )             wp_delete_post( $global_post_id );              restore_current_blog();     }     add_action( 'trash_post', 'sitewide_tags_post_delete' );     add_action( 'delete_post', 'sitewide_tags_post_delete' );          /**      * remove all posts from a given blog ($blog_id != 0)      * - used if a blog is deleted or marked as deactivat, spam, archive, mature      * - also runs if a blog is switched to a none public blog (called by      *   sitewide_tags_public_blog_update), more details on sitewide_tags_public_blog_update      * removes some posts if the limit is reached ($blog_id == 0)      * - triggered by other actions but without an given blog_id      * - number of posts to delete in $max_to_del      *       * @param $blog_id      */     function sitewide_tags_remove_posts($blog_id = 0) {         global $wpdb;         $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         $max_to_del = 10;              if( !$tags_blog_id )             return;              /* actions on the tags blog */         if ( ($blog_id == 0) && ($wpdb->blogid == $tags_blog_id) )             return;              if ( $tags_blog_id == $blog_id )             return;              switch_to_blog( $tags_blog_id );              if ( $blog_id != 0 ) {             $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE guid LIKE '" . $blog_id . ".%' OR guid LIKE '" . esc_url( $blog_id ) . ".%'" );             if( is_array( $posts ) && !empty( $posts ) ) {                 foreach( $posts as $p_id ) {                     wp_delete_post( $p_id );                 }             }         } else {             /* delete all posts over the max limit */             if( mt_rand( 0, 10 ) ) {                 $allowed_post_types = apply_filters( 'sitewide_tags_allowed_post_types', array( 'post' => true ) );                 if( is_array( $allowed_post_types ) && !empty( $allowed_post_types ) ) {                     $post_types = array();                     foreach( $allowed_post_types as $k => $v ) {                         if( $v ) {                             $post_types[] = $k;                         }                     }                     if( is_array( $post_types ) && !empty( $post_types ) ) {                         if( count( $post_types ) > 1 )                              $where = "IN ('" . join( "','", $post_types ) . "') ";                         else                             $where = "= '" . $post_types[0] . "' ";                     } else {                         $where = "= 'post' ";                     }                     $posts = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_status='publish' AND post_type {$where} ORDER BY ID DESC limit " . get_sitewide_tags_option( 'tags_max_posts', 5000 ) . ", " . $max_to_del );                     if( is_array( $posts ) && !empty( $posts ) ) {                         foreach( $posts as $p ) {                             if( preg_match('|^.*\.([0-9]+)$|', $p->guid, $matches) && intval( $matches[1] ) > 0 )                                 wp_delete_post( $p->ID );                         }                     }                 }             }         }         restore_current_blog();     }     /* complete blog actions ($blog_id != 0) */     add_action('delete_blog', 'sitewide_tags_remove_posts', 10, 1);     add_action('archive_blog', 'sitewide_tags_remove_posts', 10, 1);     add_action('deactivate_blog', 'sitewide_tags_remove_posts', 10, 1);     add_action('make_spam_blog', 'sitewide_tags_remove_posts', 10, 1);     add_action('mature_blog', 'sitewide_tags_remove_posts', 10, 1);     /* single post actions ($blog_id == 0) */     add_action("transition_post_status", 'sitewide_tags_remove_posts');          /**      * called as an action if the public state for a blog is switched      * - if a blog becomes not public - all posts in the tags blog will be removed      * - bug on 1.5.1: update_option_blog_public is only triggered if the public state       *   is changed from the backend - from edit blog as siteadmin the action isn't      *   running and the state in the blogs backend isn't changed      *      * @param int $old - old public state      * @param int $new - new state, public == 1, not public == 0      */     function sitewide_tags_public_blog_update($old, $new) {         global $wpdb;         $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );              if( !$tags_blog_id )             return;              /* the tags blog */         if ( $tags_blog_id == $wpdb->blogid )             return;              if ($new == 0 ) {             sitewide_tags_remove_posts($wpdb->blogid);         }     }     add_action('update_option_blog_public', 'sitewide_tags_public_blog_update', 10, 2);          function sitewide_tags_post_link( $link, $post ) {         global $wpdb;         $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         if( !$tags_blog_id )             return $link;              if( $wpdb->blogid == $tags_blog_id ) {             if( is_numeric( $post ) )                 $url = get_post_meta( $post, 'permalink', true );             else                 $url = get_post_meta( $post->ID, "permalink", true );                  if( $url )                 return $url;         }              return $link;     }     add_filter( 'post_link', 'sitewide_tags_post_link', 10, 2 );     add_filter( 'page_link', 'sitewide_tags_post_link', 10, 2 );          function sitewide_tags_pages_filter( $post_types ) {         if( get_sitewide_tags_option( 'tags_blog_pages' ) )             $post_types = array_merge( $post_types, array( 'page' => true ) );         return $post_types;     }     add_filter( 'sitewide_tags_allowed_post_types', 'sitewide_tags_pages_filter' );          function sitewide_tags_thumbnail_link( $html, $post_id ) {         global $wpdb;         $tags_blog_id = get_sitewide_tags_option( 'tags_blog_id' );         if( !$tags_blog_id )             return $html;              if( $wpdb->blogid == $tags_blog_id ) {             $thumb = get_post_meta( $post_id, 'thumbnail_html', true );             if( $thumb )                 return $thumb;         }         return $html;     }     add_filter('post_thumbnail_html', 'sitewide_tags_thumbnail_link', 10, 2);               function get_sitewide_tags_option( $key, $default = false ) {         static $tags_options = '1';         if( $tags_options == '1' ) {             $tags_options = get_site_option('sitewide_tags_blog');         }         if( is_array( $tags_options ) ) {             if( $key == 'all' )                 return $tags_options;             elseif( isset( $tags_options[$key] ) )                 return $tags_options[$key];         }         return get_site_option($key, $default);     }          function update_sitewide_tags_option( $key, $value = '', $flush = false ) {         static $tags_options = '1';         if( $tags_options == '1' ) {             // don't save unless something has changed             if( $key === true )                 return;             $tags_options = get_site_option('sitewide_tags_blog');         }         if( !$tags_options ) {             $tags_options = array();         }         if( $key !== true)             $tags_options[$key] = $value;         if( $flush || $key === true )             return update_site_option( 'sitewide_tags_blog', $tags_options );     }          ?>


Wordpress PHP Conflicting User Sessions

I'm using the following function to programmatically login users via the frontend:               function auto_login() {         $username = $_POST['user'];         if ( !is_user_logged_in() ) {             $user = get_userdatabylogin( $username );             $user_id = $user->ID;             wp_set_current_user( $user_id, $user_login );             wp_set_auth_cookie( $user_id );             do_action( 'wp_login', $user_login );         }          }     add_action('wp_ajax_auto_login', 'auto_login');     add_action('wp_ajax_nopriv_auto_login', 'auto_login');      However one weird issue I've run into is the following scenario:               1. User 1 logs in on PC 1          2. User 1 email is displayed as logged in in PC 1          3. User 2 logs in on PC 2          4. User 1 email is displayed as logged in in PC 2      I think this might be due to conflicting sessions but I'm not sure. I've looked up on this for quite a few days on Google yet nothing really came up which helped me. So my question is, how do I solve this issue of conflicting sessions? Thanks