Content limit
Posted by jouharabanu in Uncategorized on December 10, 2011
<?php
function chlimit($len, $terminating_string) {
global $post;
$text=get_the_content();
$text=strip_tags($text);
$text=substr($text,0,$len). $terminating_string;
return wpautop($text, 0);
}
?>
————————-
<?php echo chlimit(500, ‘….’); ?>
Excerpt functions:
Posted by jouharabanu in Uncategorized on November 29, 2011
Add read more text:
function new_jr($more) {
global $post;
return ‘<a href=”‘. get_permalink($post->ID) . ‘”><i style=”font-size:12px;”> Read More…</i></a>’;
}
add_filter(‘excerpt_more’, ‘jr’);
Control length:
function jr_length($length) {
return 20;
}
add_filter(‘excerpt_length’, ‘jr_length’);
Pagination Query
Posted by jouharabanu in Uncategorized on November 29, 2011
Query:
<?php
global $paged;
if(!$paged) {
query_posts(‘post_type=articles&showposts=6′);
}else {
query_posts(‘post_type=articles&showposts=6&paged=’ . $paged);
}
?>
After end while and before end if:
<div>
<?php previous_posts_link(); ?>
</div>
<div>
<?php next_posts_link(); ?>
</div>
Google Chrome CSS hack
Posted by jouharabanu in CSS on November 23, 2011
@media screen and (-webkit-min-device-pixel-ratio:0) {
.rm{
margin-top:7px !important;
vertical-align:baseline;
line-height:22px !important;
}
}
Random image on refresh using custom field
Posted by jouharabanu in PHP on March 2, 2011
<script type=”text/javascript” language=”javascript”>
var theImages = new Array()
<?php $n = get_post_meta($post->ID, ‘Number’, true); ?>
<?php for($i=0; $i<$n; $i++) { ?>
<?php $cur_image = get_post_meta($post->ID, ‘Image’.$i, true); ?>
theImages[<?php echo $i; ?>] = ‘<?php echo $cur_image; ?>’
<?php } ?>
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write(‘<a href=”https://www.webrecon.com/b/homepage/”><img src=”‘+theImages[whichImage]+’” alt=” ” /></a>’);
}
</script>
<script type=”text/javascript”>showImage();</script>
Excerpt Limit change
Posted by jouharabanu in Uncategorized on October 19, 2010
function new_excerpt_length($length) {
return 20;
}
add_filter(‘excerpt_length’, ‘new_excerpt_length’);
Custom Filed Manipulation New With checking
Posted by jouharabanu in Uncategorized on October 19, 2010
ID, ‘app_date’, true); ?>

