• After a day of reading posts that just confused me more, I finally worked out a simple solution to this common yet unsolved query.

    The code (coughs politely..)

    <?php
    query_posts(‘cat=1’);
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>

    and that’s it! You change the category number to whatever you like by changing (‘cat=1’) to whatever cat number you want. I think you can also change cat=1 to catname=boats’n’hoes but I am not sure. You will have to look that up. I got this code from the docs page : https://codex.www.ads-software.com/The_Loop under the heading loop examples. Their example is long and uncommon in my opinion so I striped out the bits i need.

    NOW..to implement this code, make a template page (copy pages.php and rip out it’s content but leave the generic stuff like get_sidebar etc), and put this code (above) bang in the center.

    Then..write
    <?php /* Template Name: Boats’n’Hoes */ ?>
    at the top of the page before anything else.

    Then save template page as boatsnhoes.php and put it in the same place pages.php was located.

    An example of my page is as follows :

    <?php
    /*
    Template Name: Boats’n’Hoes
    */
    ?>
    <?php get_header(); ?>
    <div id=”main”>
    <div id=”content” class=”narrowcolumn”>

    <?php
    query_posts(‘cat=1’);
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>

    </div>

    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

    cool ? That’s it. Search no longer. High 5 !

Viewing 6 replies - 31 through 36 (of 36 total)
  • From my understanding all you’re doing then is redirecting the page somewhere else, which defeats the point of using the page does it not?..

    Isn’t the point of using a page so you can have a particular URL for that content…

    So rather then having..

    yoursite.com/category/books

    You’d have..

    yoursite.com/books

    Books being the name of the page, which makes for a shorter (and maybe desired) URL.

    For page links that point offsite i can understand the use for that plugin, but for linking a page to a WordPress archive, it seems accessive, a hard-coded link could do exactly the same, without any overhead caused by loading an additional plugin..

    Am i missing something?

    Many themes create their menu from Pages, so adding a category to the menu can be a problem. The plugin lets you use a Page, which goes into the menu, to redirect to a category archive, among other things.

    Where would you put a hard-coded link for this case?

    Alongside the code handling the menu? in the template file…

    I honestly cannot figure out why you’d to install a plugin just for the sake of a single link (other then pure simplicity).. You could do the same with a htaccess rule for what it’s worth to.. We are discussing a singular link here, not several, and imo it seems overkill for something that could be handled by one line of code, either via a htaccess rule or via a hard-coded link..

    It’s un-necessary plugin additions like this that add to plugin overhead, which in turn leads to dreadfully slow sites… Where possible you should always hard-code, unless you have a particular need that warrants something more versatile(or easier).. like a plugin …

    What’s easy now, my not be the best decision for your site in the long run.. if you can hard-code, then do it, it’ll be one less area of concern should you face any performance issues somewhere down the road, be it months, weeks or years later…

    Not saying it’s a bad idea, just unwarranted for this use case.. imho..

    IMHO, it is just a lot easier for a novice to put a link in a page than to potentially bomb their site trying to change code in a template. If you are an experienced (even slightly) programmer, go for it, otherwise take the safest approach.

    Agreed, if it’s for the sake of simplicity i see no problem, we can’t all be coders/programmers .. ??

    You give alot of sound advice here mate, i’d not disagree with you just for the sake of disagreeing … ??

    All of these solutions are great for me thanks.

    Though I am running into one problem.

    I am setting up a page with a parent and applying the one category only template to that page. It all works great accept in my menu list .current_page_item is no longer being applied to that page.

    Any ideas?

    current_page_parent still gets applied to the parent item.

    Thanks

Viewing 6 replies - 31 through 36 (of 36 total)
  • The topic ‘Display the posts of one category in a Page SOLVED !!’ is closed to new replies.