Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter One Crayon

    (@beckism)

    Further testing has revealed a couple limitations of the original code posted above, and this damn forum doesn’t let me edit posts, so here’s the corrections:

    General snippet:

    if (get_query_template('page2cat') != '') {
        include(get_query_template('page2cat'));
    }

    Plugin page2cat.php file:

    case 'getpost':
    ?>
    <div id="category-page-header">
    <?php
    $post = $post_temp;
    $post = get_post($pageid);
    setup_postdata($post);
    
    if($post->post_title!=""){
        if (get_query_template('page2cat') != '') {
            include(get_query_template('page2cat'));
        } else {
                ?>
                <div id="p2c-header">
                    <h1><?php echo $post->post_title; ?></h1>
                    <?php the_content(); ?>
                </div>
            <div class="category-page-cleaner"></div>
    <?php
        }
    echo '</div>';
    $post = $post_temp;
    }
    break;

    Theme page2cat.php file:

    <div id="p2c-header">
        <h1><?php echo $post->post_title; ?></h1>
        <?php the_content(); ?>
    </div>

    Here’s another possible workaround, although not particularly elegant:

    Install the Category Access plugin, and set both the New Users and Anonymous Users sections to reveal only the public areas of the site. Then have a mechanism in place for people to request full access and you can just update that user’s profile to display the disallowed categories. Downside, you still have to deal with each user individually. Upside, you can customize exactly what categories are visible versus invisible, or visible and locked, which is a step in the right direction, at least. The plugin:

    http://dev.wp-plugins.org/wiki/CategoryAccess

    Ack, forgot to cose a code tag, sorry about that. I’d edit it if I could.

    If you don’t like IanD’s answer, and want to use the category archive:

    – Exclude category 3 from the index: <?php if ( !in_category('3')) { ?>
    - Create a link to category 3 wherever it is that you want the link. One possibility is to use list_cats()
    - Create a template file name
    category-3.php, and in that file use the same page layout template that you have on your index, minus any main-page specific code (like the excluding if statement)

    If I had my site fully converted to WordPress, I'd toss you a link for an example, but it's not up and running completely yet.

    Thread Starter One Crayon

    (@beckism)

    Beautiful, thank you so much. That’s exactly what I needed.

    I would exclude category 3 from the index.php loop, and then link to the category’s archive page from somewhere on the main page. You can set up a template page called category-3.php in order to have the category page display the same stuff as the index instead of defaulting to the archive template, as well. That way you don’t need to bother with excluding all the other categories, and you get a page for just that category.

Viewing 6 replies - 1 through 6 (of 6 total)