WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to use pages over posts for snippets in a custom WodPress site

[Resolved] How to use pages over posts for snippets in a custom WodPress site

  • 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

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    @esmi

    Forum Moderator

    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.

    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

    esmi

    @esmi

    Forum Moderator

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

    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. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How to use pages over posts for snippets in a custom WodPress site’ is closed to new replies.