WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] One blog, several rolls? (6 posts)

  1. KillerWhale
    Member
    Posted 5 years ago #

    Hello all,

    I am a French writer looking for some help as to a personalized use of WP. I have some experience with CMS (Spip) and HTML but I am a bit lost. I know precisely what I would like to do and have seen it done on other WP-powered blogs but I do not know how they did it. I am not asking for a precise tutorial, but just the general direction in which to search!

    I would like to set up a WP website for my information. At the heart of it would a blog, of course. But I would like a subset of entries to show in other pages - a selective blog roll if you wish and I don't know how to do it. Let me explain more precisely:

    I would have three main blog categories, let's say
    - Important news
    - Short news
    - And the rest (musings and such): miscellaneous

    I would like a subset of these to appear in several places, say
    - A blog page with the "important news" interspersed with the "misc"
    - A small sidebar showing only the "short news" on each page (like in a widget)
    - A welcome page showing only the "important news"

    How can I make WP present a subset of entries for some selected areas? Is there a simple way to do that or do I need to code a specific template and widget so that it would select which posts to show depending on category or hidden fields?

    I hope I was clear enough (sorry, English is not my main language!)
    Thank you in advance for any pointers you may give me.

  2. MichaelH
    Member
    Posted 5 years ago #

  3. MichaelH
    Member
    Posted 5 years ago #

    Oops, if you are are talking about POSTS (not links or blogrolls) then understand that WordPress will automatically provide you archive ability.

    Don't be confused by what an archive is--it is just a generated display of your posts at that moment. You don't do anything to create the archive, that's an automatic thing WordPress does for you. Usually, archives are date, category, tag, or author, based.

    Access to archives is typically presented via links in a sidebar under an Archive (date based), Category, or Tag Cloud, heading. Widgets, or Template Tags, such as wp_get_archives(), wp_list_categories(), wp_tag_cloud(), and wp_list_authors(), are the constructs used to present links to users to visit your various archives. The process of placing code in your Theme's Templates is explained in Stepping Into Templates and Stepping Into Template Tags.

    Once a user clicks on a Category link in the sidebar, the display of those posts can be controlled by a Category Template. Other Templates, such as Author Templates, and Tag Templates, are available if you set them up. These Templates can be coded via Template Tags such as the_title(), the_content(), or the_excerpt(), to display just a post title, the full content of the post, or just an excerpt of the post.

    Also, it is important to understand the Template Hierarchy, as that is how WordPress determines what Template to use to render the posts for reading by your readers.

    If a user visits a Category archive, then clicks on a given post title in that Category archive, the display of that single post is again presented by another Template, and again, the Template Hierarchy determines what Template displays that single post. Finally, that single post Template can be coded to display just the title, the full post content, or an excerpt.

    Hope that isn't too much to digest ;)

  4. KillerWhale
    Member
    Posted 5 years ago #

    Thank you for the pointers, very informative. I will admit it's quite dense but I think I get the gist of it. Although I am not sure how it can help, please forgive me if I am not understanding it right! Allow me to rephrase so as to see if we talk about the same things:

    All pages would be based on the same model: a "content" section and a sidebar, but they all look the same; only the selected content is different.
    The content section can be anything (blog or static page).
    The sidebar would remain the same and contain widgets, among which a subset of the blog entries (short news). So it as automatically generated archive of a predefined category, to use the right word.
    How can I force WP to get only these short news in the sidebar? Should I code a widget for that, asking WP to show only entries corresponding to a category? Or just hardcode a special loop in the template sidebar?

    Then, among these so set pages I have two special sections:
    - the blog itself (misc + long news)
    - the abridged version of the blog (long news only), which is a subset
    I would not like the reader to use the categories (in a transparent way) to browse the site. So once again I wish to automatically present the "archive" to the reader.

    I would like him to come first on the "long news" page (archive of this category), and if he so wishes, to browse on to the "blog" using a menu (archive of everything).

    Based on what I have gathered, I think I have to hardcode the menu forcing WP to show either a category subset loop (long news) or the blog in full (classic generic loop).

    Am I on the right track?
    In any case, I have to code the skeleton, am I right? There is no hidden admin functionality that would allow me that, is there?

    With many thanks!
    KW

  5. MichaelH
    Member
    Posted 5 years ago #

    You might want to look at some 'Related Posts' plugins and widgets.

    Also, if you want a sidebar, that displays just the title of the posts in the current category (current category defined as the Category Archive being viewed) then you could use something like this in a sidebar.php.

    This test to see if a category archive is being viewed, then with that category it displays the title of 5 posts from that category.

    <?php
    if ( is_category() ) {
    $cat = get_query_var('cat');
    $args = array(
      'category__in' => array($cat),
      'post_type' => 'post',
      'showposts' => '5',
      'orderby' => 'ID',
      'order' => 'DESC'
      );
    
    $posts=get_posts($args);
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php
    }
    }
    }
    ?>
  6. KillerWhale
    Member
    Posted 5 years ago #

    Thank you, I think I see clearer now. Still getting used to the architecture! I then have to code the thing myself in the template, as I thought.

    I would actually get posts from a given category instead of checking which category is being viewed but that's a simple matter of passing different arguments to get_posts. I will delve deeper into the codex and the template structures now that I know precisely what I'm looking for. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic