Forums

Show post from user in main page (3 posts)

  1. dawidhun
    Member
    Posted 2 years ago #

    Hi there!

    I'am working on a new blog and I have a litle problem with the theme. I want to show post from only specified users. (Post from admin, videos from videoadmin, etc.) and I can't find the solution.

    Here is the code from the template:

    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <?php $screen = get_post_meta ($post->ID ,'screen', true); ?>
    <img src="<?php echo ($screen); ?>" width="80" height="55" alt="" />
    <h2>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h2>
    <div class="date"> <span class="authr"> Írta: <?php the_author(); ?></span> </div>

    So I wan't to show only post from admin and not every post by ID. I have several categories and there are 2 categories which I don't want to show in main menu again, because they are already shown in sidebar (videos and news) but they are still apears between posts in the main content. (If I write a post in video category which contains only embed youtube video it is shown it sidebar but it also appears between new posts.)

    Thanks for the help.

  2. Frumph
    Member
    Posted 2 years ago #

    Right above the while (have_posts()) you could do this:

    query_posts('author_name=admin');

    That will query the current have_posts(); and seperate them so only the admin ones will display.

  3. dawidhun
    Member
    Posted 2 years ago #

    A very, very big thanks to You!

    Now it is working perfectly. I was unable to find the solution in the forum but now I know, it was wrong segment of the code where I tought the problem was. But with query it seems very symple.

    Thanks again! ;)

Topic Closed

This topic has been closed to new replies.

About this Topic