• I want a page to have an intro to a category, then to list either the posts in a category, or a list of posts (my need varies). Pretty simple.

    I have a solution to my problem, but with the last site I created I needed to make about 8 pages and it became tedious. So I wonder if there is a better solution.

    This is what I do. I create a page, say it is called Parties. Then I create a page that will hold the intro, let’s say it is called parties intro, and a category, called parties.

    I create a separate template page called parties.php with the template code at the top, lets say the template is called partytemplate. In the party.php template page I include the parties intro page, followed by the loop that calls for only the parties category. Then in the Parties page I specify to use the partytemplate as the page template.

    It is really very easy because I just use the same template and only change the template name, included page number and category number. But it also gives me a lot of flexiblity for customizing each page and the content. But, after setting this up 3 times or more I get tired of doing it (tedium is tedius!) I do this a lot. I feel it takes my WP sites to a higher level of client managability.

    I’ve tried just creating the main page, Parties, and including the php to call the posts or list of posts into that page, but have not been able to get it to work. I think that would be the easiet thing to do.

    Because it is easier to manipulate the order of pages in the menu than categories, I like to use pages. I know I can create separate category pages and customize the intro with hardcoded information, but I want my clients to be able to modify the intro and it is not always the best thing to have them playing around in the code. And, the description section for categories is not as flexible for frequent changes as a page or post is.

    Here are examples of this type of page in action:
    https://kappaluppa.com/kelley/lowry/sell-stuff/ (this is a development in progress)
    https://leadershipprogram.org/book-review/

    There you have it. If you have read this far you I thank you, but you really need to get back to work! ??

    Thanks!
    Kathy

    PS
    I am using PHP Exec, because so far RunPHP has not been added to the tested list for 2.0

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kappaluppa

    (@kappaluppa)

    I should say that if I try to include this code into the page:

    <phpcode>

    <?php query_posts(‘cat=3&orderby=post_date’); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php previous_post(); ?> <?php next_post(); ?>

    <div class=”post”>
    <h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark”><?php the_title(); ?></h2>

    <?php $more = false; the_content(‘Read More…’); ?>
    </div>
    <?php endwhile; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>

    </phpcode>

    the <!–more–> doesn’t work, and the entire post is shown.

    Sounds like you are pretty comfortable hacking around with templates and PHP. I’ve got a suggestion that might let you do it with a plug-in and just two templates (one to list posts; one to list categories). In fact, you might be able to do it with just one.

    First, get and use the Get Custom Field Values plugin. (Works in 1.5; seems OK in 2.0)

    Then add a couple custom fields for your pages that specify what category to list, and whether to list titles or posts. Have your template detect the custom fields and run an extra wordpress loop accordingly.

    Hope this helps. If you want to see how I used this plugin, email me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Anyone know of a better way to do this… (a bit wordy)’ is closed to new replies.