• Resolved antishape

    (@antishape)


    Is it possible to include a category’s posts (even if the cat doesn’t show up because I excluded it, but status is published) in a page? I’d like to add the posts of specific cat into a page to be display (headlines only) but doesn’t know how to do it. Tried different html sitemaps but they didn’t do well and the same goes to different php execute plugins to include get_post code from the wp codex. Any other way? Maybe conditional tags? If so, where do I need to include the conditional tags and how do I solve my problem mentioned above.

Viewing 9 replies - 16 through 24 (of 24 total)
  • It does not look at the page title only the slugs which WordPress creates in the right format.

    The only thing I can think of is if you had two categories with the same names, but I am sure that WordPress will append a numeric value.

    Sports
    -People slug = people
    Movies
    -People slug = people-1
    Fashion
    -People slug = people-2

    post_name is the slug and title is what you see, so it should work, one post should also still show.

    $pageslug = $post->post_name;
    $catslug = get_category_by_slug($pageslug);

    And, by the way does it matter if the both page and category aren’t visible for visitors but still published? They’re just excluded from the menu.

    I use the code on my own website, and only select a few featured categories I want so it should be fine.

    HTH

    David

    Thread Starter antishape

    (@antishape)

    If it’s the same slug WP stops me from creating another one, I need to add a number manually. But I can’t see a solution for my problem. Maybe more posts?

    Run the category people direct and you get, “Sorry, but there aren’t any posts in the People category yet.”

    So it looks like any posts have not been assigned to the people category.

    HTH

    David

    Thread Starter antishape

    (@antishape)

    I see. The problem was a plugin named Ultimate Category Excluder. Thanks a lot. Runs fine.

    Often the way!

    Can you mark this topic as resolved please.

    David

    Thread Starter antishape

    (@antishape)

    Sure, mark it right away.

    One more thing if you don’t mind: order by post title possible?

    With wp_query() there are loads of arguments, worth a look at all the options.

    Order by Title ASC

    $args=array(
        'cat' => $catid,
        'paged' => $paged,
        'orderby' => 'title',
    );

    Order by Title Desc

    $args=array(
        'cat' => $catid,
        'paged' => $paged,
        'orderby' => 'title',
        'order' => 'DESC',
    );

    HTH

    David

    Thread Starter antishape

    (@antishape)

    Thanks a lot!

    Thread Starter antishape

    (@antishape)

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘how to include posts of specific cat in a page?’ is closed to new replies.