• Resolved feron

    (@feron)


    I have got about 4 or 5 pages. For each page there is also a category of the same name, with various posts in it. What i would like to do is display the posts below the page content. so i would have:

    [Page x content]
    [category x post 1]
    [category x post 2]
    etc…

    any help is really appreciated!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • A page of posts has as example for you.

    Thread Starter feron

    (@feron)

    that is great! thanks.

    do you think instead of:

    if (is_page(’21’) ) {
    $cat = array(12);

    it would work as:

    if (is_page(‘$title’) ) {
    $cat = array(title);

    so as long as the pages and categories have the same name, the relevant content will be displayed.

    More like:

    $title="Some Page Title";
    if (is_page($title)){
    $cat=array(get_cat_ID($title));
    }

    Thread Starter feron

    (@feron)

    thanks again.

    is it possible to replace the “some Page Title” with the current page the user is on??

    So that if new pages and categories are created then i won’t have to keep updating the .php file

    Left an echo in there so you can see all the query_vars:

    <?php
    echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>";
    if ( is_page() ) {
    $title = get_query_var('page_id');  //for default permalinks
    $title = get_query_var('pagename');  //for pretty permalinks
    }
    ?>
    Thread Starter feron

    (@feron)

    Thank you very much!

    Thread Starter feron

    (@feron)

    One more thing…

    when using this code, it doesn’t seem to work with the <!–more–> quicktag. It just displays the whole post.

    any thoughts??

    Thread Starter feron

    (@feron)

    Don’t worry, fixed it with this:

    <?php global $more;
    $more = 0; ?>

    Thanks for all your help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display category posts on a page.’ is closed to new replies.