• I create a page with NEWS, n i also created some post under a new category called NEWS.

    How to display the CONTENT of the posts (in News category) in the NEWS page? Because I need the page to be customized to shows the New Archives and also the Highlighted News.

    I tried copy the code in Archives template into the Page template, but in results it doesn’t shows the archives data although the code is same.

    The code is like this….
    <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php if (is_category()) { ?>
    <h3>php echo single_cat_title(); ?></h3>
    <?php elseif (is_day()) { ?>
    ……….

    My blogs is near the end of construction~!! Just this problem make me stuck in middle~!!~~!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’m not 100% percent sure what you’re asking, but how about this solution:

    Instead of having a “news” Page (and you understand Pages are different from posts), why not just create a custom sidebar for the “News” category, so that when you click on the news category link, you get a list of all the news archives in the sidebar and all the most recent news posts in the main part.

    You could do this with the related entries plugin, perhaps.

    The code you have above is meant for displaying a header of sorts for where one is in the archives on your blog.

    If what you’re *trying* to do is just display News category posts on your News Page, take a look at how to use query_posts() to initialize the post loop in your Page template:

    https://codex.www.ads-software.com/Template_Tags/query_posts

    Thread Starter wkwebsite

    (@wkwebsite)

    Thanks alot~!! this is what i want~!
    Sorry for my poor english

    This code: <?php query_posts(‘cat=1’); ?> is to specify the query item of the page. if not,

    The following code:
    <?php while (have_posts()) : the_post(); ?>
    <h4 id=”post-<?php the_ID(); ?>”><?php the_title(); ?></h4>
    …..
    will display only the content of the page.

    coming soon: my web,
    https://xcentre.net

    Thread Starter wkwebsite

    (@wkwebsite)

    Suddenly found a problem,
    If i use the <?php query_posts(‘cat=1’); ?> within the page, the page did display all the Archives correctly.

    but for the next entry or previous entry. When i click on it, it display nothing…..it suppose to show few previous archives…but i cant c any thing….

    Need some changes for the following code??

    <?php next_posts_link(‘Previous Entries’) ?>
    <?php previous_posts_link(‘Next Entries’) ?>

    I don’t think next_posts_link/previous_posts_link will work here. You could try replacing them with posts_nav_link() along with some changes to your query_posts():

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=1&paged=$paged");
    ?>

    But note this will only work when not using custom permalinks (the default /?page_id=100 instead of /news/). Keep in mind you’re trying to make a Page behave like an archive query, and in some cases you’ll hit limits to how much you can get away with.

    Thread Starter wkwebsite

    (@wkwebsite)

    Thanks alot~!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List all Archives Content under a Page’ is closed to new replies.