Go Back   Profit Blogging Forum > Community Forum > Installing and Using WordPress

Installing and Using WordPress Post all questions on installing, upgrading, moving, importing and deleting Wordpress here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 14-04-07
realwx realwx is offline
Fresh Meat
 
Join Date: Apr 2007
Posts: 1
Default Hiding Posts in One Category

I can't get this plugin working. The main object of this plugin is to block guests from viewing any post in a set category via plugin file. I've set category number as 1. This is my first plugin, so don't yell at me!

PHP Code:
<?php
/*
Plugin Name: Bar Guests
Version: 1.0
....blah blah blah blah...
*/

$my_cat "1";

function 
applysubbyposts($the_posts) {
 global 
$wpdb;
 if(!
is_user_logged_in()) {
  foreach(
$the_posts as $key => $post) {
   
$thiscat $wpdb->get_var("SELECT category_id FROM post2cat WHERE post_id='$post->ID'");
   if(
floatval($thiscat) == floatval($my_cat)) unset($the_posts[$key]);
  }
 }
 return 
$the_posts;
}
add_filter("the_posts""applysubbyposts");
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +9. The time now is 03:28 AM.


LinkBacks Enabled by vBSEO 3.0.0 RC4

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29