maximum number of post on homepage
-
I have a site that I’ve been working on. The homepage is a template from Themler. I’m trying to get the homepage to only show the 4 most recent posts and the blog page show whatever I choose to set in the Reading section of settings.
Here’s the code I found for the blog_4.php it’s pulling it from. I did find the is_home section and I’m assuming it needs to go in there.
start code ______________________
<?php
function theme_blog_4() {
global $post;
$need_reset_query = false;
if (is_page()) {
$page_id = get_queried_object_id();
if (theme_get_meta_option($page_id, ‘theme_show_categories’)) {
$need_reset_query = true;
query_posts(
wp_parse_args(
‘category_name=’ . theme_get_meta_option($page_id, ‘theme_categories’),
array(
‘paged’ => get_query_var(‘paged’, get_query_var(‘page’, 1))
)
)
);
}
}if (!$need_reset_query && theme_is_preview()) {
global $theme_current_template_info;
if (isset($theme_current_template_info)) {
$template_name = $theme_current_template_info[‘name’];
$ids = theme_get_option(‘theme_template_’ . $template_name . ‘_query_ids’);
if ($ids) {
$need_reset_query = true;
$ids = explode(‘,’, $ids);query_posts(array(
‘post_type’ => ‘any’,
‘post__in’ => $ids,
‘paged’ => get_query_var(‘paged’, get_query_var(‘page’, 1)),
));
}
}
}
?>
<div class=” bd-blog-4″><?php
if ( is_home() && ‘page’ == get_option(‘show_on_front’) && get_option(‘page_for_posts’) ){
$blog_page_id = (int)get_option(‘page_for_posts’);
$title = ‘‘ . get_the_title($blog_page_id) . ‘‘;
echo ‘<h2 class=” bd-container-23 bd-tagstyles bd-custom-blockquotes bd-bootstrap-btn bd-btn-warning”>’ . $title . ‘</h2>’;
}
?><?php
if (have_posts()) { ?>
<div class=” bd-grid-7″>
<div class=”container-fluid”>
<div class=”separated-grid row”>
<?php while (have_posts()) {
the_post();$id = theme_get_post_id();
$class = theme_get_post_class();
?><div class=”separated-item-24 col-md-6 “>
<div class=”bd-griditem-24″>
<article id=”<?php echo $id; ?>” class=” bd-article-5 clearfix <?php echo $class; ?>”>
<?php
if (!is_page() || theme_get_meta_option($post->ID, ‘theme_show_page_title’)) {
$title = get_the_title();
if(!is_singular()) {
$title = sprintf(‘%s‘, get_permalink($post->ID), strip_tags($title), $title);;
}
if (!theme_is_empty_html($title)) {
?>
<h2 class=” bd-postheader-5″>
<div class=”bd-container-inner”>
<?php echo $title; ?>
</div>
</h2>
<?php
}
}
?><?php echo theme_get_post_thumbnail(array(‘imageClass’ => ‘ bd-imagestyles-17’, ‘class’ => ‘ bd-postimage-4’)); ?>
<?php
if (theme_is_preview() && is_singular()) {
$editor_attrs = ‘data-editable-id=”post-‘ . theme_get_the_ID() . ‘”‘;
} else {
$editor_attrs = ”;
}
?>
<div class=” bd-postcontent-9 bd-tagstyles bd-custom-blockquotes bd-bootstrap-btn bd-btn-warning <?php if (theme_is_preview()) echo ‘ bd-post-id-‘ . theme_get_the_ID(); ?>”>
<div class=”bd-container-inner” <?php echo $editor_attrs; ?>>
<?php echo(is_singular() ? theme_get_content() : theme_get_excerpt()); ?>
</div>
</div>
</article>
<?php
global $withcomments;
if (is_singular() || $withcomments){ ?>
<?php
if (theme_get_option(‘theme_allow_comments’)) {
comments_template(‘/comments_4.php’);
}
?>
<?php } ?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
<?php
} else {
?>
<div class=”bd-container-inner”><?php theme_404_content(); ?></div>
<?php
}
?></div>
<?php
if($need_reset_query){
wp_reset_query();
}
}______________ end code
- The topic ‘maximum number of post on homepage’ is closed to new replies.