Tag Archives: WordPress

Saturday, 27 October, 2007

Python Script to Import Simple Tagging tags to Wordpress 2.3

Wordpress 2.3 database now supports tags. For some reason, the Wordpress importer for Simple Tagging doesn't work for me, it imports only halfway.

I wrote this python script stp-import.py to import the tags to Wordpress 2.3 database.

[~]$ python stp-import.py

The script will ask for the Wordpress database name, the database user and password, and the Wordpress database tables prefix (default is wp) to import the tags. Tested on my database.

Database: dbname

Database user: dbuser

dbuser Password:

Wordpress table prefix [wp]: wp

215 tags imported.

Tags: WordPress, Python, tagging


Posted in Python , WordPress


Friday, 19 October, 2007

Modify WP-Cache to avoid caching Password Protected Post

This will allow the post to be seen after password is entered correctly.

Changes are made to wp-cache-phase2.php.

function wp_cache_ob_callback($buffer) {

..

/* we avoid caching incomplete files */

if (is_404() || !preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {

$new_cache = false;

return $buffer;

}

// dun cache password protect post <-- add here

global $post;

if (is_single() && !empty($post->post_password)) {

$new_cache = false;

return $buffer;

}

Tags: hacking, Php, WordPress


Posted in WordPress , Php


Thursday, 18 October, 2007

Added Twitter Tools in Sidebar

Twitter Tools is a plugin by Alex King that creates an integration between your WordPress blog and your Twitter account.

I am using WP-Cache plugin also, so twitter updates may not be seen immediately (for up to an hour).

Modified Twitter Tools so that tweets from my blog posts don't show the tinyurl link.

Tags: WordPress


Posted in WordPress


Sunday, 3 June, 2007

Showing Digg Popular Stories

Digg Popular Stories are now shown at the bottom of some of the categories and browse tag pages.

The categories include Diversion, Game, Science, Sports, Technology, World, Php and Python. The tags include Astronomy, environment, nba, php, python, Microsoft and video.

I wrote python scripts to retrieve the popular stories provided by Digg api and format the data in html, ready to be included in my wordpress pages.

Categories:

Diversion, Game, Science, Sports, Technology, World, Php and Python.

Tags:

Astronomy, environment, nba, php, python, Microsoft and video

Archives: June, July, August, September, October, November, December.

January, February, March, April, May.

Tags: WordPress, Python, Digg, Php


Posted in Php , WordPress , Python


Thursday, 10 May, 2007

Adding Html Title for Tag Pages

This is done by modifying the function wp_title in general-template.php (add the below code).

if ( empty($title) ) {

$tag = get_query_var('tag'); // assume

if ( !empty($tag) )

$title = "Browse by ".$tag;

}

Tags: Php, tagging, WordPress


Posted in WordPress


Saturday, 14 April, 2007

Related Tags Navigation added

I am using plugin Simple Tagging. I made a slight modification to STP_RelatedTags and outputRelatedTags functions and uses STP_RelatedTags to show the related tags to the current tag being viewed. Basically, if a post is tagged with A and B, then tag A and B are related.

I also use the below to generate the browse tags path.

Eg. navigate_tags('php+Wordpress') will produce >> php >> Wordpress

The tag navigation is equivalent to the one I used in Sky Explorer for application menu. :)

function get_tags($tag) {

return explode("+", $tag);

}

function navigate_tags($tag) {

$tags = get_tags($tag);

$tagUri = '/tag/';

$link = '';

$tagfmt = '>> <a href="%link%">%name%</a> ';

$tagvars = array("%link%", "%name%");

$nav = '';

foreach ($tags as $t) {

$link .= (($link != '')? '+' : '') . $t;

$nav .= str_replace($tagvars, array($tagUri.$link, $t), $tagfmt);

}

return $nav;

}

Tags: tagging, Php, WordPress


Posted in WordPress , Php


Saturday, 7 April, 2007

Showing Only WordPress Top Categories

My sub-categories links are not working! I decided to show only the top categories on my sidebar. The following describes how I do it:

Modify function get_categories in category.php

  • Add show_top option in $defaults.

    	$defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
    

    'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '',

    'include' => '', 'number' => '', 'pad_counts' => false, 'show_top' => false);

  • Add to the sql where criteria if $show_top is true.

    	if ($show_top)
    

    $where .= ' AND category_parent = 0';

  • Modify my sidebar.php

    <?php wp_list_cats('sort_column=name&hierarchical=0&show_top=true') ?>
    

I notice the various variables used for the options (eg. $hierarchical) are never initialized anywhere. There is this odd looking statement extract($r); (see the function documentation here), now, I understand how this works! ;)

Tags: WordPress, Php


Posted in Php , WordPress