WordPress.org

Ready to get started?Download WordPress

Forums

Category Page (25 posts)

  1. ObertonGluek
    Member
    Posted 8 years ago #

    Hi there,

    I wish to create a kind of "Sublog" as a page, which ONLY shows the posts that have the "Movie Reviews" tag. I've read a few explanations on the internet but I can't quite grasp what I'm supposed to do.

    I've copied the page.php and renamed it to sublog.php, I've then created a new page using the "Sublog".php template but it returns a black page with only the title "Movie Reviews" and no posts, so I don't know where to start so that I can tell it to ONLY shows posts with the "Movie Reviews" tag.

    Please help, or I'm going to go mental.

  2. ObertonGluek
    Member
    Posted 8 years ago #

    By the way, this is the code I have so far for my "Sublog" template, which I want to show ONLY posts with the tag "Movie Reviews", just as posts are displayed on the homepage.

    <?php
    /*
    Template Name: Sublog
    */
    ?>
    <?php get_header(); ?>

    <div class="content">

    <div class="primary">

    <div class="item">

    <div class="pagetitle">
    <h2 id="post-<?php the_ID(); ?>"><a>" rel="bookmark" title='Permanent Link to "<?php the_title(); ?>"'><?php the_title(); ?></a></h2>
    <?php edit_post_link('<img src="'.get_bloginfo(template_directory).'/images/pencil.png" alt="Edit Link" />', '<span class="editlink">', '</span>'); ?>
    </div>

    </div>

    </div>

    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

  3. moshu
    Member
    Posted 8 years ago #

    Pages and Categories are different things. Don't mix them.
    What you need is a category template > http://codex.wordpress.org/Category_Templates

  4. ObertonGluek
    Member
    Posted 8 years ago #

    Moshu, I've already searched and found that page. It does exactly what I want but I just don't get it. Maybe it's 'cause it's 4am and I'm tired but it just sounds like a load of mixed information.

    I want a page called "Movie Reviews", when the user clicks that I want the page to show all posts with the tag "Movie Reviews". Can you tell me what to do to acheive that, because that page takes a simple question, and turns it into a complicated answer.

  5. moshu
    Member
    Posted 8 years ago #

    I want a page called "Movie Reviews"

    If you meant a Page (made in Write > Write Pages) that's the problem. Catgeory templates are NOT pages. You don't see the category templates in the "Page Templates" dropdown.
    They have their own life :) and are recognized by WP.

    Let's say, your movies category has the ID# 7... you create a template file category-7.php.
    The easiest way to do it: save your archive.php file as category-7.php. You can edit the file, you can even have a different layout (define its style in the stylesheet) and
    having a link to cat=7 will display this "category archive" on it's own template.

  6. ObertonGluek
    Member
    Posted 8 years ago #

    Ok, I understand, but how do I create the link in the menu, if I don't use "Manage Pages > Write Page"? And how do I view the file once it's created, so that I can start editing it?

    Are you saying it's not possible to create a new page link in the menu, which shows only posts of one category?

    Edit: I have now copied the archives file and renamed it "category-4" ... what to do now is the confusing part.

  7. indigokid
    Member
    Posted 8 years ago #

    The way I've done it was simply to create a new category called Movie Reviews. I then edited all movie review posts by checking the category marked movie reviews, hey presto -a new category, link and page containing only movie reviews.

    Unless I'm missing what you trying to do.

    You could also make this a child category to parent category if you want it to appear in another cat as well.

  8. ObertonGluek
    Member
    Posted 8 years ago #

    Yes, that's that I want. But I want the title "Movie Reviews" to be displayed in the menu, not in the sidebar and, also, I don't want the movie review posts to appear on the main blog.

  9. moshu
    Member
    Posted 8 years ago #

    1. You can exclude any category from showing up in the sidebar menu. Just read about the parameters of the template used for displaying your categories.
    http://codex.wordpress.org/Template_Tags#Category_tags
    2. I don't know what your "menu" is - I assume is a horizontal list on the top; you can always add anything to it manually ;)
    3. There are plugins that can exclude posts from certain categories from being displayed on your main page.
    e.g. http://ryowebsite.com/?p=46

  10. ryoken
    Member
    Posted 8 years ago #

    not sure what you mean by the first half (possibly you may need to add the title to your category template and add an if statement to your sidebar file so it doesn't show?)

    the 2nd half of that is a job for query_posts(). more info at http://codex.wordpress.org/Template_Tags/query_posts

    edit: moshu - whats the difference between that plugin and query_posts?

  11. dzr
    Member
    Posted 8 years ago #

    This is how I have done something similar for a client. They post job vacancies as news posts, but they also wanted a page in the top-level page menu called Jobs. So the job listings, while really posts and so available via the category link, also show up on a page. What you need to do is create a template for the page, then create a blank page in WordPress and tell it to use your template. In the template you then override the query_posts argument.

    <?php
    /*
    Template Name: Movie Reviews
    */
    ?>
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged&category_name=Movie Reviews");
    load_template( TEMPLATEPATH . '/index.php'); //loads index
    ?>

    Note that I've used the index.php file for displaying all the posts in a Movie Reviews category, but you can load any template you like. If you had created a special category-#.php file you could load that instead, and then your Movie Reviews page would look the same whether someone followed the category link or the link in your main menu.

    Does that help?

    Best, Darren

  12. moshu
    Member
    Posted 8 years ago #

    ryoken,
    Usually, it is easier for users to activate a plugin than to mess around with template files, Loop and code :)

  13. ObertonGluek
    Member
    Posted 8 years ago #

    DZR, that works perfectly. If you were a woman, I would MARRY YOU! hahaha

    One more thing, how do I change the title of this new page? Currently it is:

    "Archive for the 'Movie Reviews' Category"

    ... and I simply wants:

    "Movie Reviews"

    I'm not sure how to override it. Sorry for seeming like a n00b. I know how to write PHP, but I've never used WordPress before so it's all new to me.

  14. ObertonGluek
    Member
    Posted 8 years ago #

    Nevermind. I created a copy of index.php and saved it as moviereviews.php, then told the script to load that as the template. Then I put the Loop code inside moviereview.php and now I'm editing that to get the results I want.

    Thanks a lot for all your help; now I just need to exclude all "Movie Review" categorys from the main blog.

    Thanks again,

    Phil.

  15. dan_imal
    Member
    Posted 7 years ago #

    ObertonGluek:

    I, on the other hand, do not know PHP from the IRS =-)

    Slight exaggeration but, really, I am truly a noob so I was wondering if you would be willing to share the code for your moviereviews.php file.

    I also followed moshu's post and have a "Videos Category" page set up of which I would like to change the title.

  16. moshu
    Member
    Posted 7 years ago #

    As for "my part" - if you followed my posts and have a category template (either catgeory.php or catgeory-XY.php) then open it to edit in a text editor and find what is displaying its title. Usually it is on the top.

  17. dan_imal
    Member
    Posted 7 years ago #

    Hmmmmm...

    Here is what I have that is giving me the page with title:

    Archive for the 'video' Category

    <?php
    /*
    Template Name: cat-page--from-index-video-cat.php
    */
    ?>
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged&category_name=video");
    load_template( TEMPLATEPATH . '/index.php'); //loads index
    ?>

    <?php get_header(); ?>

    <div class="content">

    <div class="primary">

    <?php include (TEMPLATEPATH . '/theloop.php'); ?>

    </div>

    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

    I cannot see what is displaying it's title.Any ideas? Should I be looking in the original index.php file?

  18. dan_imal
    Member
    Posted 7 years ago #

    Also, I see that I get none of the images associated with the original posts on this page. ?

  19. moshu
    Member
    Posted 7 years ago #

    The Codex (and reading) is your best friend:
    http://codex.wordpress.org/Template_Tags/the_excerpt

  20. dan_imal
    Member
    Posted 7 years ago #

    Thanks for the link. Researching...researching...

    It seems to be saying that I have no choice but to live with excerpted content?

    Since the tag has no parameters (i.e. "yes" or "no") I cannot "boss it around" to get it to show all the images associated with a post?

  21. moshu
    Member
    Posted 7 years ago #

    There is (almost) always a workaround...
    http://guff.szub.net/2005/02/26/the-excerpt-reloaded/
    (now that you did your homework, you deserve it... [just kidding])

  22. dan_imal
    Member
    Posted 7 years ago #

    Thanks!

    I will check that out. I am sure I will be back with more questions.

    I am also looking through Category Templates

    Must join the "real world" now. I'll be back...

  23. dan_imal
    Member
    Posted 7 years ago #

    Huzzah!

    Thanks, moshu (and indirectly, ObertonGluek) for all your help.

    For the title of the page (from the loop):

    <?php /* If this is a category archive */ if (is_category()) { ?>
    '<?php echo single_cat_title(); ?>' Category Archive

    where <?php echo single_cat_title(); ?> is the name of the category and everything else, before or after, on the same line makes up the rest of the title of the page.

    For showing full posts (including images) in the archive page (and also from the loop):

    <?php if (is_archive() or is_search()) {
    the_content();
    } else {
    the_content("Continue reading '" . the_title('', '', false) . "'");
    } ?>

    The second instance of the_content was formerly the_excerpt

  24. tchandler
    Member
    Posted 7 years ago #

    moshu? someone? i'm in need of a little help with the same problem.

    i've created a category template which i want to apply to a page in order to display all posts in a particular category.

    it pulls the posts in correctly, but the page looks like an archive page even thoughtthe template that i created is a copy of index.php with the query_post added. how can i get the page to display like my main page and not as an archive?

    http://letsgetawesome.net

    here's the template i created:

    <?php
    /*
    Template Name: Media Template
    */

    get_header(); ?>

    <div class="content">

    <div class="primary">

    <?php query_posts("cat=18");
    include (TEMPLATEPATH . '/theloop.php'); ?>

    </div>

    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

  25. tchandler
    Member
    Posted 7 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic

Tags