WordPress.org

Forums

[resolved] How to use pages over posts for snippets in a custom WodPress site (5 posts)

  1. sixfootjames
    Member
    Posted 3 years ago #

    Hi,

    For a while now, I have been using posts to "pull" certain bits of content onto a home page or any other page. The problem with this is that if someone clicks on that link it will go to.

    http://www.example.com/decaf-for-all
    instead of
    http://www.example.com/news/decaf-for-all

    Until now, this is the code snippet I would use pull the post out of the db, but I would like to know if this is possible for pages too please.

    <?php query_posts('category_name=book-now-button&posts_per_page=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a class="book-now" href="<?php the_permalink() ?>">&nbsp;</a>
    <?php endwhile;?>

    Essentially, rather than any posts, I want to use only pages, so that WordPress works more like a general CMS than blog.

    Many thanks

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    You can't use any of the category parameters with Pages as Pages simply don't have categories. Or tags. So you would need to look at another way of selecting specific Pages via query_posts etc.

  3. sixfootjames
    Member
    Posted 3 years ago #

    Thanks Esmi.

    I gave this some more thought.

    To keep it simple, I would still use the posts (for the news items) but in WP, I could create a subpage called "News-items" and make it submenu under "News".

    In my Reading Settings (in WP), I could then tell the posts page to use the "News-Items" page.

    What should then happen according to my understanding, is that when someone clicks on a post from the home page, it should redirect to...

    http://www.example.com/news/news-item

    Yet, this is not happening. Is there another configuration setting I might be missing?

    Many thanks

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Post will have the permalink that you configured in Settings -> Permalinks. See Using_Permalinks.

  5. sixfootjames
    Member
    Posted 3 years ago #

    Thanks again Esmi.

    It seems this option is working for me then.

    /%category%/%postname%/

    This at least results in...

    http://www.example.com/news/news-articl-name

    Other pages just link as normal then. :)

Topic Closed

This topic has been closed to new replies.

About this Topic