CSS for mobile, iphone

<link rel="stylesheet" href="iphone.css" media="only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)" />
OR
<link media="handheld, screen and (max-device-width: 480px)" href="iphone.css" type="text/css" rel="stylesheet" />

Truncation text, word, sentence

Limiting or Truncating strings using PHP

Truncation at word breaks

Truncation at sentence breaks

http://www.the-art-of-web.com/php/truncate/

Count Character and DO NOT break word

$str = get_the_content();
$charset = ‘utf-8′;
$len = iconv_strlen($content, $charset);
$max_len = 97;
$max_cut_len = 10;
if ($len > $max_len)
{
$str = iconv_substr($str, 0, $max_len, $charset);
$prev_space_pos = iconv_strrpos($str, ‘ ‘, $charset);
if (($max_len-$prev_space_pos) < $max_cut_len) $str = iconv_substr($str, 0, $prev_space_pos, $charset);
$str .= ‘ …’;
}
echo $str;

list child pages

<?php

$children = get_pages(‘child_of=’.$post->ID.’&parent=’.$post->ID);
if( count( $children ) != 0 ) {
?>
<ul>
<?php
foreach ($children as $pagg) {
$option .= ‘<li>’;
$option .= ‘<a href=”‘.get_page_link($pagg->ID).’”>’;
$option .= $pagg->post_title;
$option .= ‘</a></li>’;
}
echo $option;
?>
</ul>
<?php
}
?>

<?php $children = get_pages(‘child_of=’.$post->ID.’&parent=’.$post->ID); if( count( $children ) != 0 ) {  ?> <ul>                    <?php foreach ($children as $pagg) { $option .= ‘<li>’; $option .= ‘<a href=”‘.get_page_link($pagg->ID).’”>’; $option .= $pagg->post_title; $option .= ‘</a></li>’; } echo $option; ?>                    </ul>                    <?php } ?>

csstrick

CSS tricks ul li and table row

First row : green

ul li:first-child {
color:green;
}

Last row : Red

ul li:last-child {
color:red;
}

Alternate row bg color : Gray

ul li:nth-child(2n+2) {
background-color:#ccc;
}

Fifth row : Bold

ul li:nth-child(4) {
font-weight:bold;
}

More here: http://css-tricks.com/5452-how-nth-child-works/

Pull content from specific page, post with preserve formatting

$my_id = 100;
$post_id_100 = get_post($my_id);
$content = $post_id_100->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;

List Specific Pages with Title, Excerpt and Link

<div>
<?php global $post; $myposts = get_posts(‘post_type=page&include=100,200,300&orderby=post_date&order=ASC’); ?>
<ul>
<?php $posts_counter = 0; ?>
<?php foreach( $myposts as $post ) : setup_postdata( $post ); $posts_counter++;?>
<li>
<div>
<h2><a href=”<?php the_permalink(); ?>”><?php the_title(”); ?></a></h2>
<div><?php the_excerpt(); ?></div>
<div><a href=”<?php the_permalink(); ?>”>Read more</a></div>
</div>
</li>
<?php endforeach; wp_reset_query(); ?>
</ul>
</div>

simple but useful jquery functions

<script type=”text/javascript”>
jQuery(“.pageclass #pageid fieldset:first”).attr(“id”, “users-profile-core”); //add attribute like id in first
jQuery(“.pageclass #pageid p:last”).addClass(“bottom”); //add class in last p
jQuery(“.page-id .myclass”).addClass(“roundedgray”);
jQuery(‘p’).removeClass(‘myClass yourClass’);
jQuery(‘p’).removeClass(‘myClass noClass’).addClass(‘yourClass’);
</script>

8 Steps to clean a hacked WordPress blog

http://knowit.co.nz/2010/01/8-steps-to-clean-a-hacked-wordpress-blog

Contact Form 7 – spam controller QUIZ

<p>Please answer the following<br />
[quiz quiz-4711 class:quiz "1+1=?|2" "1+2=?|3" "1+3=?|4" "1+4=?|5" "1+5=?|6" "1+6=?|7" "1+7=?|8" "1+8=?|9" "2+1=?|3" "2+2=?|4" "2+3=?|5" "2+4=?|6" "2+5=?|7" "2+6=?|8" "2+7=?|9" "2+8=?|10" "3+1=?|4" "3+2=?|5" "3+3=?|6" "3+4=?|7" "3+5=?|8" "3+6=?|9" "3+7=?|10" "3+8=?|11" "4+1=?|5" "4+2=?|6" "4+3=?|7" "4+4=?|8" "4+5=?| 9" "4+6=?|10" "4+7=?|11" "4+8=?|12" "5+1=?|6" "5+2=?|7" "5+3=?|8" "5+4=?|9" "5+5=?|10" "5+6=?|11" "5+7=?|12" "5+8=?|13" "6+1=?|7" "6+2=?|8" "6+3=?|9" "6+4=?|10" "6+5=?|11" "6+6=?|12" "6+7=?|13" "6+8=?|14" "7+1=?|8" "7+2=?|9" "7+3=?|10" "7+4=?|11" "7+5=?|12" "7+6=?|13" "7+7=?|14" "7+8=?|15" "8+1=?|9" "8+2=?|10" "8+3=?|11" "8+4=?|12" "8+5=?|13" "8+6=?|14" "8+7=?|15" "8+8=?|16" ]