CSS for mobile, iphone
Aug 16th
<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
Aug 8th
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
Aug 8th
$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
Jul 24th
<?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 } ?>

CSS tricks ul li and table row
Jul 13th
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;
}

Pull content from specific page, post with preserve formatting
Jul 12th
$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
Jul 10th
<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
Jul 7th
<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>
Contact Form 7 – spam controller QUIZ
Jun 11th




Recent Comments