Display published and future post

0

$args = array(
‘post_status’ => ‘publish,future’,
);

Preserve post/page formatting with limited character

0

$my_id = 162;
$post_id = get_post($my_id);
$content = $post_id->post_content;
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]>’, $content);

//all content from the post.
echo $content;

//limited characters from the post.
echo $content = substr($content,0,300);

Vertically Center content in DIV (without table)

0

<div style=”display: table; height: 150px; width:500px; border:1px solid red;”>
<div style=” display: table-cell; vertical-align: middle;”>
<p style=”border:1px solid green;”>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse sagittis nisl eu nibh porttitor molestie. Nam scelerisque tempor sapien, non euismod sapien lacinia non.</p>
</div>
</div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse sagittis nisl eu nibh porttitor molestie. Nam scelerisque tempor sapien, non euismod sapien lacinia non.

Add Content via CSS

0

#topRightmenu ul li + li:before { content: “|”; }

CSS for mobile, iphone

0
<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

0

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

0

$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

0

<?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 } ?>

CSS tricks ul li and table row

0

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

0
$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;
Go to Top

Page optimized by WP Minify WordPress Plugin