Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:04:19+00:00 2026-06-10T02:04:19+00:00

I am trying to alter my WordPress theme to display the latest posts from

  • 0

I am trying to alter my WordPress theme to display the latest posts from a specific tag. It currently lists the latest posts overall.

Here is part of the code that it uses:

<?php
    if ( is_home() ) {
        $args=array(
            'showposts'=> (int) get_option('aggregate_homepage_posts'),
            'paged'=>$paged,
            'category__not_in' => (array) get_option('aggregate_exlcats_recent')
        );
        if (get_option('aggregate_duplicate') == 'false') {
            global $ids;
            $args['post__not_in'] = $ids;
        }
        query_posts($args);
        global $paged;
    }
    $i = 0;
?>
<?php 
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php
        $i++;
        $et_is_latest_post = ( $paged == 0 && ( is_home() && $i <= 2 ) ) || !is_home();
    ?>
        <div class="post entry clearfix<?php if ( $et_is_latest_post ) echo ' latest'; ?>">
            <?php
                $thumb = '';
                $width = $et_is_latest_post ? 170 : 67;
                $height = $et_is_latest_post ? 110 : 67;
                $classtext = 'post-thumb';
                $titletext = get_the_title();
                $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
                $thumb = $thumbnail["thumb"];
            ?>

            <?php if($thumb <> '' && get_option('aggregate_thumbnails_index') == 'on') { ?>
                <div class="thumb thumbcont">
                    <a href="<?php the_permalink(); ?>">
                        <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
                        <span class="overlay"></span>
                    </a>
<a class="thumb<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>" href="<?php bloginfo('url'); ?>/<?php echo $category[0]->category_nicename; ?>"><?php echo $category[0]->cat_name; ?></a>
                </div>  <!-- end .post-thumbnail -->

            <?php } ?>

            <h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <?php get_template_part('includes/postinfo'); ?>

            <p class="postsummery">
            <?php
              $excerpt = get_the_excerpt();
              echo string_limit_words($excerpt,20);
            ?>
            </p>

            <a href="<?php the_permalink(); ?>" class="more"><span><?php esc_html_e('Read More','Aggregate'); ?></span></a>
        </div>  <!-- end .post-->
<?php endwhile; ?>
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    else { ?>
         <?php get_template_part('includes/navigation','entry'); ?>
    <?php } ?>
<?php else : ?>
    <?php get_template_part('includes/no-results','entry'); ?>
<?php endif; wp_reset_query(); ?>

While doing some research, I found some details of how to do this:
http://codex.wordpress.org/Template_Tags/get_posts

However, my very limited knowledge of PHP coding and lack of understanding how my current code works with the examples provided, I cannot find a way to do it. Can you guide me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:04:21+00:00Added an answer on June 10, 2026 at 2:04 am

    You simple add ‘tag’=>the tag u wanted listed, after array( at line3
    why well cause that’s the array containing the arguments that then will be passed to the get posts function that makes a call to the database, the arguments that you got to choose from can be find here http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
    And the full code would look like so

       <?php
        if ( is_home() ) {
            $args=array(
                'showposts'=> (int) get_option('aggregate_homepage_posts'),
                'paged'=>$paged,
                'tag'=>"the tag u want shown",
                'category__not_in' => (array) get_option('aggregate_exlcats_recent')
            );
            if (get_option('aggregate_duplicate') == 'false') {
                global $ids;
                $args['post__not_in'] = $ids;
            }
            query_posts($args);
            global $paged;
        }
        $i = 0;
    ?>
    <?php 
        if (have_posts()) : while (have_posts()) : the_post(); ?>
        <?php
            $i++;
            $et_is_latest_post = ( $paged == 0 && ( is_home() && $i <= 2 ) ) || !is_home();
        ?>
            <div class="post entry clearfix<?php if ( $et_is_latest_post ) echo ' latest'; ?>">
                <?php
                    $thumb = '';
                    $width = $et_is_latest_post ? 170 : 67;
                    $height = $et_is_latest_post ? 110 : 67;
                    $classtext = 'post-thumb';
                    $titletext = get_the_title();
                    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
                    $thumb = $thumbnail["thumb"];
                ?>
    
                <?php if($thumb <> '' && get_option('aggregate_thumbnails_index') == 'on') { ?>
                    <div class="thumb thumbcont">
                        <a href="<?php the_permalink(); ?>">
                            <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
                            <span class="overlay"></span>
                        </a>
    <a class="thumb<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>" href="<?php bloginfo('url'); ?>/<?php echo $category[0]->category_nicename; ?>"><?php echo $category[0]->cat_name; ?></a>
                    </div>  <!-- end .post-thumbnail -->
    
                <?php } ?>
    
                <h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                <?php get_template_part('includes/postinfo'); ?>
    
                <p class="postsummery">
                <?php
                  $excerpt = get_the_excerpt();
                  echo string_limit_words($excerpt,20);
                ?>
                </p>
    
                <a href="<?php the_permalink(); ?>" class="more"><span><?php esc_html_e('Read More','Aggregate'); ?></span></a>
            </div>  <!-- end .post-->
    <?php endwhile; ?>
        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
        else { ?>
             <?php get_template_part('includes/navigation','entry'); ?>
        <?php } ?>
    <?php else : ?>
        <?php get_template_part('includes/no-results','entry'); ?>
    <?php endif; wp_reset_query(); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify my wordpress theme (inove) to display all comments in the
I am trying to alter column datatype of a primary key to tinyint from
Total noob here with javascript. I'm trying to alter a function. This is the
I'm trying to create a wordpress theme. After following some tutorials I've written this
I am trying to work this function in wordpress theme the way where I
I'm having hard time trying to use teasers post in my wordpress theme (based
I am trying to select the sub-menu item from a Wordpress default sidebar menu,
I am currently developing my own Wordpress theme and have been recently working on
Trying to install this contact form: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme I'm getting HUGE gaps between fields: http://themeforward.com/demo2/features/contact-form/
I am trying to alter the default preview post button when posting on wordpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.