Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Blog inside page WordPress

  • SOLVED

Hi there
i've set up a website using wp, so i used it as a cms, now i need to integrate a blog and i would like to embed inside a page


what i did:
-in page.php i've added an include if the page visited is "blog" in my case.
-inside the include (blog.php) i'm using this (bad) code


<div class="blog">
<?php if (is_page(669)) query_posts('showposts=0'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="article"><h1>"><?php the_title(); ?></h1>
<p><?php the_content_limit(1300, "continue...") ?></p> <?php endwhile; else: ?><p>no latest article!</p><?php endif; ?>
</div>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>

it doens't works so good because it duplicate the posts. the other big problem is i can't add a pagination, i've installed the plugin wp page navi but the link for the second page returns me in the first one.

i've tried a lot of tutorials on google but still nothing

thanks for attention

Answers (4)

2011-09-02

Utkarsh Kukreti answers:

What do you mean by "duplicate the posts"?


Utkarsh Kukreti comments:

For the paging, try replacing

<?php if (is_page(669)) query_posts('showposts=0'); ?>
with

<?php if (is_page(669)) query_posts(array('showposts' => 0, 'paged' => get_query_var('paged'))); ?>


qny comments:

hey i replaced the code and now the pagination works! thanks!

could you help me to figure out the duplication posts and that weird simbol near the title?

for duplicate post i mean that after my formatted entries (i choose a list tag) wp still add again the same posts not formatted. try to see this with the help of firebug!


Utkarsh Kukreti comments:

Please post the contents of page.php


qny comments:

here you are
<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/

get_header(); ?>
<?php do_action('wp_menubar','menu'); ?>

<div id="content" class="narrowcolumn" role="main">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">' . __('Read the rest of this page ;', 'kubrick') . '</p>'); ?>

<?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'kubrick') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php if (is_page(669)) include ("blog.php"); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(__('Edit this entry.', 'kubrick'), '<p>', '</p>'); ?>

<?php comments_template(); ?>

</div>

<?php wp_pagenavi(); ?>

<?php get_footer(); ?>


Utkarsh Kukreti comments:

Use this for your blog

<div class="blog">
<?php if (is_page(669)): query_posts(array('showposts' => 0, 'paged' => get_query_var('paged'))); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="article" style="list-style:none;"><h1>"><?php the_title(); ?></h1>
<p><?php the_content_limit(1300, "continue...") ?></p> <?php endwhile; else: ?><p>no latest article!</p><?php endif; ?>
</div>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
<?php endif; ?>
</div>




And add this to your style.css

.entry ul li:before, #sidebar ul ul li:before { content: ""; }


Utkarsh Kukreti comments:

And this for page.php

<?php

/**
* @package WordPress
* @subpackage Default_Theme
*/

get_header(); ?>
<?php do_action('wp_menubar','menu'); ?>

<div id="content" class="narrowcolumn" role="main">
<?php if (is_page(669)): include ("blog.php"); else: ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">' . __('Read the rest of this page ;', 'kubrick') . '</p>'); ?>


<?php wp_link_pages(array('before' => '<p>' . __('Pages:', 'kubrick') . ' ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(__('Edit this entry.', 'kubrick'), '<p>', '</p>'); ?>



<?php comments_template(); ?>


<?php endif; ?>
</div>



<?php wp_pagenavi(); ?>



<?php get_footer(); ?>


qny comments:

i edited a bit your code and now it's cleaner.

but i have still the same problem with double post