Support » Fixing WordPress » Exclude specific category ID's from Author template

  • Resolved brian317

    (@brian317)


    Just trying to merge this type of request:
    query_posts( array ( 'category_name' => 'reviews, it-services, news', 'posts_per_page' => 10 ) );

    somewhere in the author template, which first does a
    “if ( have_posts() );”
    then does a
    “the_post();”
    then does a
    “rewind_posts();”
    then does the
    “while ( have_posts() ) : the_post();”

    //then displays all the author posts….

    Where could I fit my wish!? I can’t wait to get as smart as the pros with wp language but ’til then it’s one bug at a time!

Viewing 10 replies - 1 through 10 (of 10 total)
  • It’s hard to say without seeing more of the code, but from what you’ve put, it should probably go after the first loop and before the second loop. So after the rewind_posts(), and before the while loop, add your query_posts and the second loop should use that query.

    ok..so I have a question.. I have a blog page.. I would like it to exclude a category of posts..
    so they only show up on a page called picks.. in the category picks…
    how do I do that.. sorry for jumping in here.. I’m lost

    May need to add to the query

    query_posts('author=1&cat=1,2,3');

    unless the template already assumes all posts to be author posts, even outside the loop. Which I’m not sure of.

    wow I didn’t think it was going to be that easy! you were right – thank you dkotter.

    trool – i’ve got some similar pages – basically you’ll create a custom template (which means right at the top you’ll create a new name here:

    <?php
    /**
    Template Name: Home Page
     *
     * @package WordPress
     * @subpackage Alfa Theme
     */

    Then you need to add your custom loop, mine looks like this,

    query_posts( array ( 'category_name' => 'reviews, it-services, news', 'posts_per_page' => 10 ) );
    
                    global $more;    // Declare global $more (before the loop).
    
                    // The Loop
                    while ( have_posts() ) : the_post();
                    echo '<div class="post">';
                    echo'<h3 class="entry-title"><a href="';
                    the_permalink();
                    echo'" rel="bookmark" >';
                    the_title();
                    echo'</a></h3>';

    basically you just then paste the code you want to use below, you could pull the standard stuff from functions.php where the loop is defined or write a more basic one.

    after you display all your elements, you need these lines specifically

    endwhile;
    
                    // Reset Query
                    wp_reset_query();
                    ?>

    Brian, could you post your completed author page code? I’m trying to understand how the template works with the query to produce author posts, since author is not specified in the actual query.

    thanks!

    trool,

    you can easily create a category tab in your main nav with a custom menu, it will open a category called “Picks” on a page called “Picks” in archive.php. But if you want to do other stuff with your content best to go the custom template route as described above.

    Hi deepbevel, I’m using the standard “author.php” file that comes with wordpress’ default theme twentyeleven, the only change i’ve made is a copy paste of my first code snippet at the top of this thread, per dkotter’s precise instruction. If you’re still having trouble i’ll use a pastebin thing and put it up in there.

    If you’re trying to create a custom page i’m not sure how it would work, the page is called when someone clicks on the author’s name, as it displays above each post, in the theme.

    I looked at the twentyten author.php code, I’m trying to understand how the template gets author posts if it just uses the standard loop, also wondering how your query works if you don’t specify author in the code.

    the link is generated in deep in wordpress somewhere, the template is not looking for an author, the link is already set to display an author.

    I noticed get_author_link() in the functions.php, if you want a hard-link somewhere that will probably work in a loop on any page.

    aha, thanks, I saw

    <a class='url fn n' href='" . get_author_posts_url( get_the_author_meta( 'ID' ) ) . "' title='" . esc_attr( get_the_author() ) . "' rel='me'>" . get_the_author() . "</a></span>" ); ?></h1>

    in the author.php template. Just wasn’t really sure what it was doing.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Exclude specific category ID's from Author template’ is closed to new replies.