Skip to content

Category: Coding

Programming and scripting topics.

How to style wordpress default comment form for TwentyTen?

Go to your theme open comments.php if you have one:

and find the line:

comment_form();

Replace it with this code which you could change as you like:

$commenter = wp_get_current_commenter();

$fields =  array(
 'author' => '<p>' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /><label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span>*</span>' : '' ) .
 '</p>',
 'email'  => '<p><input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span>*</span>' : '' ) .
 '</p>',
 'url'    => '<p><input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /><label for="url">' . __( 'Website' ) . '</label>' .
 '</p>',
);

$defaults = array(
 'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
);

comment_form($defaults);

For more information check the wordpress docs: http://codex.wordpress.org/Template_Tags/comment_form

How wordpress more link can navigate to top of the full article window?

By default, when you click on the Read More link, the web page loads and then “jumps” to the spot where the <–more–> tag is set in the post. If you do not want that “jump”, you can use this code in your theme’s functions.php:

function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');

Function to get wordpress theme URL

This function will return the theme directory URL so you can use it in other functions:

get_bloginfo('template_directory');

Alternatively, this function will echo the theme directory URL to the browser:

bloginfo('template_directory');

So an example for an image in the themes images/headers folder would be:

<img src="<?php bloginfo('template_directory'); ?>/images/headers/image.jpg" />

How to add a scallable background image to your site?

If you want to add an image that resizes according to the monitor or the browser size just follow the steps:

First put the image exactly after the opening <body> tag:

<body>

<img src=”images/bg.jpg” class=”bg” />

Then go to the CSS and add this:


img.bg {
     bottom:0;
     min-width:1024px;
     position:fixed;
     right:0;
     width:100%;
}

Then add some exception CSS for IE6, because it doesn’t get this stuff to work well.

Modifying the Tags Results Page for Joomla K2 + Creating a K2 Template Over Ride

This is a handy little guide, if you want to change the way that your Tag Results page is displayed.
As default, when you click on a Tag Link in a K2 Item, it will produce a page showing all full items which have that particular tag.

Now, if you Items contain a lot of information or you have a lot of Items with the same Tag, you will end up with quite a long list.

This little guide will explain how to reduce the displayed data to show just a snippet of the Item information plus add a bit of extra information.

Firstly, we are going to have to modify the generic.php file, this is located on components/com_k2/templates/
Now, If you do not want to modify this core file, then you can create a new K2 template first.

How to rename the home link on the main wordpress menu to something else?

If you are using thematic child theme go to thematic-functions.php file in your child theme and add this:

//    Add a Home link to your menu
function childtheme_menu_args($args) {
$args = array(
'show_home' => 'Home',  //here change Home to whatever you like
'sort_column' => 'menu_order',
'menu_class' => 'menu',
'echo' => true
);
return $args;
}
add_filter('wp_page_menu_args','childtheme_menu_args');