最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Posts from a category on homepage with category archieves page default css

matteradmin10PV0评论

I am trying to accomplish something.

First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.

Update: what i think am trying to achieve is:

category archieve pages and tag archieves has the same design (css) as the homepage.

i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.

Any help please

I am trying to accomplish something.

First am using two themes on my blog, on the mobile theme which is carrington, i would love to add five posts from a certain category or tag for example "Tech" to the footer of the theme or immediately after the recent posts.

Update: what i think am trying to achieve is:

category archieve pages and tag archieves has the same design (css) as the homepage.

i just need to copy the design and contents of one category page archieve and place it in the footer section of my homepage.

Any help please

Share Improve this question edited Mar 28, 2017 at 14:49 Tarrmie de Man asked Mar 24, 2017 at 8:11 Tarrmie de ManTarrmie de Man 431 silver badge7 bronze badges 0
Add a comment  | 

3 Answers 3

Reset to default 1
    $args = array(
        'posts_per_page' => 5,
        'cat' => 77 // 77 - id category
    );

    $query = new WP_Query( $args );

    // loop
    if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
            $query->the_post();
echo '<li>';
the_post_thumbnail();
            echo '<a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
        }
    } else {
        // posts not fount
    echo 'posts not fount';
    }
    wp_reset_postdata();

Replace the category id (77) with the id of the category you need. You need to add this code to the template. In the place where you want to display the records (for example: index.php).

<?php query_posts('category_name=xxxxxxxxxxxx&order=dsc&showposts=12'); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<br clear="all"><br />
        <?php endwhile; ?>
        <?php endif; ?>

Here you see category_name=xxxxxxxxxxxx here change the xxxx to your category slug and you are done

my mission was achieved by using some part of the code suggested above.

I changed the xxxxx to my category slug then below that code i posted all of my loop and that was it.

So if you want it to have your post page design:

  1. copy this

  2. copy the whole of your loop and paste under and save

Post a comment

comment list (0)

  1. No comments so far