Archive for the ‘WordPress Bookmarks’ Category

Listing subpages in Wordpress

Monday, April 30th, 2007

I was looking for a way to list sub pages in a navigation bar if you were either on the “parent” page or one of it’s sub pages. I found this page on Clioweb that was perfect.

What’s also nice is that it gives you the variable $parent_id to play with if you need to. Copied from his site:

<?php
$page = $wp_query->post;
$parent_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ID ='$page->post_parent;'");
if(!$parent_id) $parent_id = $post->ID;
?>

Then, to actually generate the HTML for the page list, I use the following code in the body of my page template:

<?php if(wp_list_pages("child_of=".$parent_id."&echo=0")): ?>
<ul id="subnav">
<?php wp_list_pages("title_li=&child_of=".$parent_id."&sort_column=menu_order&depth=1");?>
</ul>
<?php endif; ?>

Wordpress: Make home page show latest post (in the “single post” format)

Saturday, April 28th, 2007

In a custom wordpress theme design I was working on tonight, I was trying to do as the title describes - make the home page show only one post (yes I know there’s already a built in way to do this) but I wanted it to show up the same way the single view shows it - with the comments expanded and the comments form visible, etc. If you know of another/better way to do this, please say so in the comments. But this DID do the trick. I found this page in the support archives. The idea was to create your index.php to look like you wanted (ie. exactly like the “single.php” page) but add this before you start the loop:

<?php
$i=0; // Initialize to Zero;
if (have_posts()) :
while (have_posts()) : the_post();
if ($i==0) {$recentpostid = $post->ID; $i=$i+1;}
endwhile;
endif;
//get only the latest post
$posts = query_posts( 'p='.$recentpostid."'");
?>

and then you start your loop like you normally would…

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Worked for me!

Update As Danny pointed out in the comments - there’s a simpler way to do this. Put the following code on the page (I put it before the loop and it worked)
<?php $wp_query->is_single = true; ?>
Much simpler :)

Plugin Competition

Saturday, May 7th, 2005

While I *really* wish I could enter into the Wordpress plugin contest - the fact of the matter is my schedule doesn’t open up until next month - after the contest has closed for judging. But it sounds like it will be run again - so I should be able to enter it next time.

In any case - if I need ideas for plugins to “get back into the swing” - hopefully this “developers wanted” list will still be up and running in June.

Spam Bot Protection Measure

Thursday, December 30th, 2004

Here’s a few steps you can do to protect against some of the spambots:

Master-SpamBot IP, deny this!
[found via weblogtoolscollection]

Script to rename wp-admin folder

Thursday, December 30th, 2004

JD just sent me this link to his site:

Script to rename your wp-admin folder.
As he says - it’s not a foolproof method to protect your site, but certainly not a bad idea.

A few good links

Tuesday, December 28th, 2004

UploadBin
Kind of like pastebin - but for files, and Mark offers it up so you can download and host it on your own server.

wp-hashcash
A version of Spam Stopgam Extreme.
[seen on a lot of sites, but most recently on PhotoMatt and Weblogtoolscollection]

WordPress “Suggest” plugin
Kind of like “Google’s Suggest” feature - for WordPress Searches.
[blogginpro]

WP-lists Plugin
Centralized List management (through wordpress?)
[blogginpro]

Red Alt - WordPress Index Builder

Sunday, November 21st, 2004

Red Alt - WordPress Index Builder

WordPress Design Sandbox

Friday, November 12th, 2004

WordPress Design Sandbox
If you want to work on a design for your WordPress blog, here’s a static version of the default layout so you can tweak the stylesheet locally. Great idea.
[via WeblogToolsCollection]

Anatomy of a WordPress Theme

Thursday, November 11th, 2004

This link is going around - but I still want to save it for myself…

Anatomy of WordPress theme
A list of templates that you can create for a theme (for WordPress 1.3)

Blocking Proxy-IP based Spam

Friday, November 5th, 2004

There’s a number of anti-spam tricks floating around. I will hopefully be compiling a list of the most interesting ones very soon for my own reference. In the meantime, this one seems like a simple enough hit that can get rid of quite a bit:

(As posted on the Daily Irrelevant) …If your IP address is on a list of known open proxies (mostly used by email spammers, but recently by comment-spammers as well) you will not be able to post comments.

[via Matt]