• Hi,

    The topic might be a little confusing, so let me explain.

    I have a travel blog, on which I add posts from countries into categories. Instead of search I’d like the users to use https://www.podroznikowo.pl/mapa to navigate and search older posts.

    When clicked on a country it would redirect them to a page https://www.podroznikowo.pl/slowenia-2 which would show the posts.

    Up to this point I was able to get posts from a category, but I’d liek them to be shown like on the main page https://www.podroznikowo.pl/

    the code I have now is:

    <?php
    /* Template Name: Slowenia */

    get_header(); ?>

    <div id=”primary” class=”site-content”>
    <div id=”content” role=”main”>

    <?php query_posts(‘cat=4&showposts=4’); ?>

    <?php if ( have_posts() ) : ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( ‘content’, get_post_format() ); ?>
    <?php endwhile; ?>

    <?php endif; // end have_posts() check ?>

    </div><!– #content –>
    </div><!– #primary –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Could you please help me?

Viewing 2 replies - 1 through 2 (of 2 total)
  • check content.php – there might be some conditional statements which regulate how posts are shown at the posts page;

    please post the full code of content.php – please use the pastebin https://codex.www.ads-software.com/Forum_Welcome#Posting_Code

    Hi Podroznikowo,

    Something to consider is to change the link to the location page with the feed of articles. Instead of directing your user to a “page” (like you would create as a litteral page in the WP admin) you might be better off pointing them to a category (like “/category/slowenia”).

    In terms of the code that you have written, I am pretty sure that your main issue is with this line of code:

    <?php query_posts('cat=4&showposts=4'); ?>

    To my knowledge, “showposts” is not an array index that query_posts() looks for. If you only want 4 posts to show up, you are better off using the “posts_per_page” key. Thus your code would look like this:

    <?php query_posts('cat=4&posts_per_page=4'); ?>

    I hope that this helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show posts from a single category on a page the way they're shown on the main’ is closed to new replies.