コード例 #1
0
ファイル: functions.php プロジェクト: saqibamin/icl
function get_user_posts($user_id = 0)
{
    global $conn;
    $post_per_page = get_posts_per_page();
    $current_page = get_current_page();
    $offset = ($current_page - 1) * $post_per_page;
    $posts_query = "SELECT *\n\t\tFROM posts\n\t\tWHERE user_id={$user_id}\n\t\tORDER BY publish_date DESC\n\t\tLIMIT {$offset}, {$post_per_page}";
    $posts_query = mysqli_query($conn, $posts_query);
    $all_posts = array();
    // $counter  = 0;
    while ($post = mysqli_fetch_assoc($posts_query)) {
        // $all_posts[$counter++] = $post;
        $all_posts[] = $post;
    }
    return $all_posts;
}
コード例 #2
0
ファイル: category.php プロジェクト: saqibamin/icl
			</div>

			<div class="post-excerpt">
				<?php 
    $post_content = strip_tags($post['post_content']);
    // less than 200
    if (strlen($post_content) > 200) {
        $post_content = substr($post_content, 0, 200) . '...';
    }
    echo $post_content;
    ?>
			</div>
		</div>
<?php 
}
// end foreach
?>

<div class="pagination">
		
	<?php 
$total_posts = get_cat_posts_count($category_id);
// 25
$post_per_page = get_posts_per_page();
// 4
$total_pages = ceil($total_posts / $post_per_page);
for ($i = 1; $i <= $total_pages; $i++) {
    echo '<a href="' . BASE_URL . '?cat=' . $category_id . '&paged=' . $i . '" class="' . ($i == get_current_page() ? 'current-page' : '') . '">' . $i . '</a>';
}
?>
</div>