• Resolved wpbless

    (@wpbless)


    Need the titles and excerpts of posts to appear on different pages according to the post’s category.

    Searched plugins for a long time. List Category Posts is wonderful but not set to work with 3.1 yet.

    Would RSS work for this? How do you get it to publish specific categories’ content in specific places on pages?

    Would a page template work for this? What do you name the template? Are there templates for templates? Where would you put them?

    Would tweaking existing php work for this? Which php file would you tweak for putting categorized content titles and excerpts on pages? What code would you insert, and where?

    Many many thanks for any answers or links to answers!!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Would a page template work for this? What do you name the template? Are there templates for templates? Where would you put them?

    very likely.
    naming is not important – call one of the page templates ‘uncle_george.php’ if you like.

    the best template for a template is probably either index.php or single.php of the theme you are working with – this way you have all the correct html structure in place.

    you save your page templates in the theme folder alongside the other files such as index.php, single.php, style.css …

    there are some requiremants for a page template: http://codex.wordpress.org/Pages#Page_Templates

    to define what the page template is going to show, you could either use ‘get_posts()’ or ‘query_posts()’

    http://codex.wordpress.org/Template_Tags/get_posts
    http://codex.wordpress.org/Function_Reference/query_posts

    Thread Starter wpbless

    (@wpbless)

    Thank you VERY much.

    It probably says in the codex link you provided, but sometimes these essential details are so buried, I hope you don’t mind if I ask…

    Does it matter where in the php you put the snip?

    Thread Starter wpbless

    (@wpbless)

    The codex says:

    Toward the bottom of the Write > Page administration panel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled “Page Template.” From there you can select which Template will be used when displaying this particular Page.

    (by the way, in 3.1, the Page Template under Appearance/Editor.)

    Sorry that I think I need to be spoon-fed on this.

    I am thinking of

    1. starting with the Page template here and pasting it into Notepad.

    2. pasting this code in there somewhere: BUT WHERE?
    <?php
    query_posts(‘category_name=HOME&showposts=12’);
    while (have_posts()) :
    the_post();
    ?>

    3. Saving this file with the same name as the category_name attribute. I.e., home.php (All my page names are going to match the category names whose content the pages need to display.)

    4. Putting this home.php file in my themes folder.

    Is this pretty much it?

    Huge thanks.

    Thread Starter wpbless

    (@wpbless)

    BTW… Is my code snippet correct?

    thanks thanks thanks

    do you mean this essential comment:

    <?php
    /*
    Template Name: Snarfer
    */
    ?>

    this goes right at the top of the page template.

    this name ‘Snarfer’ will show in the dropdown under ‘page attributes’ ‘template’ in ‘edit page’ page in the dashboard; where you can assign it to the page that you are writing/editing.

    another example of a page template:
    in Twenty Ten: onecolumn-page.php

    Thread Starter wpbless

    (@wpbless)

    I meant the snip above:

    <?php
    query_posts('category_name=HOME&showposts=12');
    while (have_posts()) :
    the_post();
    ?>

    I think that is for pulling the posts from a category of the name Home, and to show the 12 most recent posts from that category.

    Also need to figure out how to get it to display the post’s excerpt.
    (To make the excerpt, each post will use <–more–> in Add Post.)

    I think I’m getting closer to finding what snip to use for the excerpt, but I don’t know how this fits together, or where to use it with the query_posts snip above.

    <?php the_excerpt(); ?>

    For “Read more…” I’m reading the snip would be something like:

    <?php
    function excerpt_ellipse($text) {
       return str_replace('[...]', ' <a href="'.get_permalink().'">Read more...</a>', $text); }
    add_filter('the_excerpt', 'excerpt_ellipse');
    ?>

    But where to put this so I can start testing it… that might be the question…

    sincere thanks.

    [Please post code snippets between backticks or use the code button.]

    Thread Starter wpbless

    (@wpbless)

    A link on “Read more…” above?
    I pasted that from Notepad into this discussion.

    i missed one of your replies – trying to answer now:

    1. starting with the Page template here and pasting it into Notepad.

    imho, best probably to start with index.php (or single.php – if the front page is somehow different) of your theme.

    2. pasting this code in there somewhere: BUT WHERE?

    <?php
    query_posts('category_name=HOME&showposts=12');
    while (have_posts()) :
    the_post();
    ?>

    your starting code might already have the

    while (have_posts()) :
    the_post();

    part, maybe even with a if( have_posts() ) : before these lines;
    then add this query_posts('category_name=HOME&showposts=12'); before all of it.
    not totaly sure, but check the capitalisation of ‘HOME’ as it might be important.

    3. Saving this file with the same name as the category_name attribute. I.e., home.php (All my page names are going to match the category names whose content the pages need to display.)

    home.php is not a good idea – there are some names reserved for the standard template files: http://codex.wordpress.org/Template_Hierarchy

    4. Putting this new template file in my themes folder.

    yes

    some more links (you might have already found them):
    http://codex.wordpress.org/Function_Reference/the_excerpt
    http://codex.wordpress.org/Template_Tags/the_content
    http://codex.wordpress.org/Customizing_the_Read_More

    Thread Starter wpbless

    (@wpbless)

    THANK YOU!

    I’m doing something wrong, but I’m getting closer.

    Here’s what I did:

    I created a WP page called CITIES.

    I also created a category called CITIES.

    I created a post and assigned it to two categories: CITIES and HOME.
    (My customer wants text on the nav bar to be in upper case.)

    I pasted the single.php template into Notepad.

    Above if (have_posts()) I pasted
    query_posts(‘category_name=CITIES&showposts=12’);

    the_excerpt();

    Gave the name cities.php to this result:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I put cities.php in the currently active theme folder.

    But the CITIES page is still blank. http://cultureblog.modelpeopleinc.com/cities/

    Apologies for being so clue-less. I’m still reading codex files, but maybe somebody will take pity on a moron.

    (I’ll try index.php now too.)

    Thread Starter wpbless

    (@wpbless)

    Tried it with the index.php template.

    Named it cities.php. Put it in the folder of the currently-active theme. But the post that I tagged for the CITIES (and HOME) category isn’t showing up on the CITIES page. http://cultureblog.modelpeopleinc.com/cities/

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thread Starter wpbless

    (@wpbless)

    It needs to appear on the HOME page, and on the CITIES page.

    Putting it in two categories causes it to be posted twice to the home page.

    Any solution for that???

    Thread Starter wpbless

    (@wpbless)

    Tried it with the index.php template.

    Named it cities.php. Put it in the folder of the currently-active theme. But the post that I tagged for the CITIES (and HOME) category isn’t showing up on the CITIES page. http://cultureblog.modelpeopleinc.com/cities/

    Used “Copy To Clipboard” from pastebin for what follows, as requested. I hope this is permissible:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thread Starter wpbless

    (@wpbless)

    Gave up on this. Tried custom Menu. That didn’t work.

    Am using a text widget with a URL for a page that lists all posts in a category.
    http://cultureblog.modelpeopleinc.com/category/categorynamehere-cultureblog-modelpeopleinc/

    Poses different problems, but this might work.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Need to post categorized content titles/excerpts on different pages.’ is closed to new replies.