Posts in the category "WordPress".

Plugplugplugplugin!

I installed ScriptyGoddess’s Next/Previous link for archive pages. Also put a little PHP logo in the bottom right corner of the Php code bits I have. If I ever have anything else (I’ve been meaning to put a CSS thing), I’ll do logos for them too. Also, the red bits are the ones you (definitely) have to change.

Bah, this article got me excited that YES it’s possible to assign two classes to an element. Well, in the comments it said that IE doesn’t handle it well. Have to test that out though.

[edit @ 23:18] Now I’m going to install Service Pack 2 (Durand’s recommendation, I’m holding you responsible if something happens!!! :wink: ). Wish me luck. Good bye cruel world!! *dramatic exit* [/edit]
[edit] I didn’t [/edit]

Tweaking the calendar

My calendar didn’t have a link to the current month, so I added it. There’s a function called get_month_link(year,month) which returns the URL to a monthly archive page (not the link). So, I put it in some <a> tags:

<caption><a href="'.get_month_link($thisyear,$thismonth).'"><img src="'.get_settings('siteurl').'/image location/'.$month[zeroise($thismonth, 2)].'.gif" /><img src="'.get_settings('siteurl').'/image location/'.date('Y', $unixmonth).'.gif"></a></caption>

Of course, if you don’t have images in place of the original texts, you just put the link part around what there is in the <caption> of the calendar table. Basically it’s

<caption><a href="'.get_month_link($thisyear,$thismonth).'">whatever you do to get the month and year</a></caption>

Ironing and folding and sorting by date

I added the Nicer Archives code snippet from WP Wiki. I tried to use the “upgraded” versions of it (from Weblog Tools Collection) but they borked — big time.

When you enter the page, it shows the posts of the current year. Then you can sort the posts by date, title, or category; ascending or descending; and from all years or one year at a time (there is only one year, for now). The original script had a possibility sort by author but because there’s only me, I commented it out.

Time format is date.month.year.

On to the archives »

The calendar showed as January 2004 so I started to look for a way to remove it. Easier said than done. Well, not really, but I didn’t think of echoing the variable in my if-test to see what it’s out put was. This is what I wrote (first):

<?php $thispage = $_SERVER[‘HTTP_HOST’].$PHP_SELF;
    if ($thispage != “www.mypage.xxx/blog-folder/pagename.php“) { ?>
     <!-- CALENDAR -->
     <li id=”calendar”>
        <?php get_calendar(); ?>
     </li>
<?php } ?>

http_host + php_self return the url of a php page a without the http (as that’d be the protocol)

Then I tried what $_SERVER[‘REQUEST_URI’] does and it echoed the path without the host. Nifty. Thus, I changed the code to

<?php $thispage = $_SERVER[‘REQUEST_URI’];
    if ($thispage != “/blog-folder/pagename.php“) { ?>
     <!-- CALENDAR -->
     <li id=”calendar”>
        <?php get_calendar(); ?>
     </li>
<?php } ?>

[edit: Nov 22/Dec 15, ’04/Jan 5, ’05] I had an oddly titled post which messed up the archive. Well, not exactly *mess* but because it had an less-than sign at the beginning it was archived under L, but first alphabetically. After some testing, I figured out how to prevent this. From the WP Wiki I found a function sanitize_title_with_dashes which I used in the archive code, this is in the function archive_header: This worked when my odd titles included only one starting with A. But when there was one with D, I noticed the code didn’t work. Why? Because it compares the first letter if the current title to the previous one and the query sorts the odd titles at first. Well, I took another approach to this. All odd titles will be categorized under # (I know it means ‘number’ but here it’s just some non-alphabetic character). A new try, a * I had in one of the titles wouldn’t be recognized, probably because the line starting with preg_match matches only letters and numbers, so I changed that to match any one character (at the beginning). Hopefully this will prove working with my strange titles…

elseif ('title' == $orderby) {
preg_match('/.{1}/i', $post->post_title, $match);
$thisletter = ucfirst($match[0]);
if (!ctype_alpha($thisletter)) { $thisletter = '#'; }
if ($thisletter != $previous) {
$output .= "<br/>".$thisletter;
}
$previous = $thisletter;

The highlighted part checks if the first letter of the title is NOT an alphabetic character, if it’s true that it’s NOT one, the letter will be a ‘#’. Now all the odd titles will be grouped at the beginning of the list of titles (or end if the order’s descending) . [/edit]

All new all things me

The redesign of all things me is finally done! Now I’m just waiting for the domain to start working to the right direction. (aaagh, 1 week free trial period and the domain won’t be registered before I pay the bill — but they won’t send me the bill!!)

So, I’ve changed from green/purple to purple (or lilac or violet — I don’t know!). I was planning to have my “colour depth of three” (black, white, purple) on the site but black was so bright!! So I made it a little “foggier” (#444444). I’ve used Harrington font in the pictures. I don’t know where that splash came from; I was looking for a nice bullet (which, in the end, I didn’t use) and then I decided to add it in front of the post titles to separate them more clearly when there’re several posts in one day.

The layout is flexible. That means the text is as wide as it can be (minus the menu). I used to have it at max 760 pixels which I — on a 1024×768 screen — didn’t like but I had to think about you little people. I mean, people with little screens — whoops!

Now that I have a proper domain I’ve enabled ping/trackbacks (not yet on all posts cause I have to click through them all dammit). I said bye-bye to category pictures. They just didn’t fit anywhere. Hmm… I *could* put them on a post’s individual page.

On to another topic. I finished reading Dark Tower VI: Song of Susannah on September 27. At 4:40 am. Ssshhh, don’t tell anyone! Now I’m waiting for DTVII to arrive in the bookstores. It was published on 21st and when I went to ask when I could expect it to be on the shelves they said “in two weeks”, so I’ll probably check it this week (as I have to drag myself to the center on Friday — 2 months of work starts, again) and then, naturally, next week.

Now I’ll add the category image thingy…

I also changed from Pagination to "vBulletin Style page navigation".

Yesterday night I was glued to the screen reading a blog (Myrskymurmeli) that had a convenient page navigation (hmm… actually I think it’s the default WP navigation which I’d removed to enable ScriptyGoddess’s Pagination… anyway) and I read the whole blog to the very first entry… thank gawd there wasn’t a lot more entries — I would’ve been stuck to the screen till the wee hours.

I’m starting work tomorrow… I’ll be working for 3 months’ worth and doing as-long-as-I-can/want-days until I’ve filled the required hours. I’ll be working till the end of spring I bet ;)

Some logic to monthly archives

This is wonderful! I just came across a way to get the monthly archives in chronological order while categories and main page are shown in the default way, descending order by date.

Adding &order=ASC to rewrite rules (the one that has index.php?year…) does the trick neatly!

Finland and Canada are skating against each other tonight. World Cup hockey. *fingers crossed* I’m NOT going to stay up and watch it though.

Wiping cold sweat

For a moment I was panicking. The database connection didn’t work on my or my hostess’s site (so the problem was with the server) and it seemed to go on forever. I updated my index page already, telling about problems, but then suddenly everything works. Phew.

Now, what was I supposed to write before I was cruelly denied access.

First of all, my sister spotted a silly sight while playing Splinter Cell:

Screenshot from Splinter Cell

That handsome chap there is Sam Fisher — the one in black. There’s a slaughter house at one point in the game, and one of the soldiers my sister (or Sam Fisher) shot, froze with his hands still holding the gun. Also the grimace is awfully funny but you probably can’t see it well. You can see the other corner of the mouth being darker and thus being drawn downward. (speak of the devil: Splinter Cell music just started playing on Winamp)

I saw two episodes of Dr. Phil this week. He’s supposed to be some really popular tv “shrink” but I don’t know… He sounds exactly like the guidance counsellor, Mr. Mackey, in South Park!! Hoookay? Sorry, it’s more like “m’kay” with Mr. Mackey but “hookay” with Dr. Phil. They sound the same, nevertheless.

I wanted to show the last update on my Booklog, but I’d removed the date of the post from my static pages. Well, running php from a post is not possible on WP. I found a wonderful plugin by Mark.

Also, “installed” Customizable post listings plugin (from Coffee2Code; wonderful site and wonderful name!!) and put a list of 5 most recently updated posts (including static pages, which is actually really good) and 5 most recently commented posts (currently there are only 2 though… :???: ) on the menu.

Kick yer MTs and Bloggers to the curve

I’m always thinking “now, where’s that page that looked like this and this and this” (or any info I need: “what did the text say under the picture on page so-and-so, on the right hand side corner below the title such-and-such” A slight case of photographic memory I guess. Only I don’t always *remember* the things I can see in my mind’s eye.)

WordPress references for me and you:

I installed a Breadcrumb plugin. I was going to add headers on the category pages but remembered this and thought it could be niftier. It doesn’t show on the main page but if you go to different archives or categories it shows where you are. On a single post’s page it shows all the categories the post belongs to in a comma separated list.

I also hacked a forget user info (from Scriptygoddess) option to the comments. I don’t like forms remembering my information and WordPress sets a cookie as a default.

Joined David Copperfield fanlisting. Today there was a “David Copperfield — Greatest escapes” on TV (Gawd, he’s cute! And funny). In 1997 I saw Copperfield in Finland (and he’s coming here again this December). After the show I’d written in my diary that I was feeling very unreal. It was a wonderful performance with his flying and getting-sawn-in-two and others that I can’t remember. In the tv show he said that after some outsider had shouted “move your feet” after the saw had cut Copperfield in two, they had a crew member shout the same thing in every show after that. I can’t remember if that was in the performance I saw.

The tour then was called Dreams and Nightmares and I started my dream diary soon after that. Named it “Dreams and Nightmares”.

Static

Inspired by the idea presented at Digitus, Finger & Co. I installed MooKitty’s Show Categories plugin and modified it with the code in a comment by Paul.

“Static pages” are posts but hidden from the index page, archives, and category listing. They can be found by search, however. I “staticised” my booklog and the page about me already but I still have some more work to do. I decided to keep commenting on for the static pages. I removed “lots” of things, though. It’s easy: Just add

<?php if ($cat != x) { ?> HIDDEN STUFF HERE <?php } ?>

around the bits you want to hide (x being the ID number of the category you are hiding). That bit of code means “if the category number does NOT equal x, show the bit between { and }”.
I hid the date, time posted, and word count.

The breadcrumb code is located outside the WP loop so at first I didn’t know how to get the category info for if-clauses (for hiding the breadcrumb from static pages). I found a function in_category(x) where x is the number of the category. It returns true or false. So, I put a

<?php if ( !in_category(x) ) { ?> HIDDEN STUFF HERE <?php } ?>

around the breadcrumb code and now it’s gone from the static pages just as I like it.

Making static (or more like non-entry) pages this way makes it easier for them to keep up with the modifications I make to the index page. I used to have the static pages as php pages where I had copied the “header” and “footer” of each page.

Subcategories away

I was trying to get rid of subcategories in a parent category (annoying when a post is NOT assigned to the parent category but still shows in it) with the help of a post by Andrew Hall. No luck. I studied the code and dared to comment out another bit that looked “right” and now it seems to work:
in wp-blog-header.php (found in the WP root folder) around line 293 (under “Category stuff for nice URIs”), comment out (= add /* before the code and */ after it) the line

$whichcat .= get_category_children($cat, " OR category_id = ");

Also, updated wpPaginate plugin (by Scriptygoddess) to .1.1.

UPDATE
On WP1.5. this is found in wp-includes/classes.php, on line 413. Comment out

$whichcat .= get_category_children($q[‘cat’], ” OR category_id = “);

UPDATE
On WP1.5.1.(1) these are found in wp-includes/classes.php on lines 393, 396, 420; below Category Stuff and Category Stuff for Nice URIs. Comment out the lines starting with $whichcat .= get_category_children

Hack-hackety-hack

Note to self: Adding a nicer search function a la Raena. I removed the counting of search results because I use pagination so if there are 10+ results it would show “There are 10 results…” even though there were more. Also, I changed the length ($excerpt_length) of “the_exceprt_rss” function in template-functions-post.php, line 194.

Added a Statistics hack for my own fun. Note to self: Doesn’t show private messages.

An observation: I don’t understand what the word count really counts… it always seems to be missing a few words. E.g. it claimed there was 18 words before this note here, and I counted 19…

I downloaded a lot of goldie oldie games from Pelit [Games] magazine’s site (you need to be a subscriber and registered to download): New Adventures of Zak McKracken, Maniac Mansion Deluxe, and Mario Forever. I also downloaded Codename Gordon, a 2D game with a Halflife motif. I was looking for Space Quest: Replicated, a fan-made game, but didn’t find it.

*insert proper curse word here* I’m going crazy with these mad insects flying around. They’re attracted to my desk lamp. If only I could whack ’em.