Webmaster Blog

Webmaster Resources

⇒Category: Home » Wordpress » RSS

PageNavi not working on front page if you exclude categories

Well did you ever use the command “query_posts(’cat=-xx’);” to exclude certain posts from your main page? I did!
Recently I found out that my pagenavi was no longer working.


A solution is to get this plugin that provides cms-like functions to exclude certain categories completely from specific parts of your blog.


If you don’t want to exclude posts from the sidebar you might also want to take a glance at this plugin: Simply Exclude

Trailing Slash and SEO URL’s

I noticed that there is a small bug in Wordpress 2.3 if you are using seo friendly url’s.
The “Trackback” and “Subscribe to the comments feed” links on the single.php have two slashs at the end and return a 404 page.
If you want to fix that open: /wp-includes/link-template.php
Find “get_post_comments_feed_link” and remove “trailingslashit(” as well as the closing round bracket after “($post_id)”.

Wordpress: Count SQL Queries

For a developer loading speed is a crucial factor, therefore it is necessary to check how many SQL queries are needed to build a page.

To do that in Wordpress add this code anywhere in your template and it will show the queries that are needed until that specific part. If you want to know how many queries are needed for loading the full page then put the code in the footer.php

<? php echo get_num_queries(); ?>

You are able to use it several times inside your template, so insert it anywhere as many times as required.That’s great for locating potential “troublemakers”

Source:Playworkplay.com

Wordpress: WP-Postratings “get_highest_rated”

get_highest_rated is defined at postrating-stats.php and is responsible for displaying the content as well.

Wordpress: Default Post

If you should come in the situation that you always need the same post over and over again, e.g. if you use wordpress as a CMS then I have a useful trick for you.

We have to edit the function “the_editor“, which is defined at general-template.php!

Open the file and find the function; now inside the function find

textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s

Straight after the %s add the text that is supposed to be your default post. If it’s a complex string you can safe the text in a variable e.g. $defaulttext = “here goes my php code”; and simply add $defaulttext after %s, but before the closing textarea tag!

Wordpress: Default Custom Fields

If you should ever come in the situation that you want a default custom field on your “write page” you should first of all create a draft with your default custom fields.
After that go to your phpMyAdmin interface and lookup the postid.
Once you got the postid simply goto “wp_postmeta” and find the postid of that draft. Change the id to zero.
VoilĂ  now you will have the custom field you defined in the draft at your write page. This is especially handy if you always need the same custom field because you can simply copy it.

Page 1 of 212»