1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress Category Issue

Discussion in 'Web Design' started by Montgomery76, May 28, 2013.

  1. Montgomery76

    Montgomery76 Registered Member

    Joined:
    Apr 17, 2013
    Messages:
    52
    Likes Received:
    13
    Hi guys,
    Is there a way to replace the default category listing in Wordpress with a page? Need to add content to the Category listing...

    I want the following structure

    Home -> CategoryPage (page - not archive)->Post
    domain.com / CategoryPageName / Postname

    Please note that the CategoryPage should be an editible fully functional Page in Wordpress - not the default category listing.
    I know that I could list posts from a page. But then the URL to the Article/Post will be wrong. I want the articles to be placed UNDER the page...

    Any ideas?

    Thx guys,
    m.
     
  2. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,358
    Likes Received:
    5,420
    Gender:
    Male
    Location:
    South Africa
    Home Page:
  3. Montgomery76

    Montgomery76 Registered Member

    Joined:
    Apr 17, 2013
    Messages:
    52
    Likes Received:
    13
    Kindof solved it...found this code. If I create a page and a category with the exact same slug PHP get the content data from the page...


    <?php
    if ( is_category() ) {
    // Get current category slug
    $cat = get_query_var( 'cat' );
    $cat_object = get_category( $cat );
    $category_slug = $cat_object->slug;

    // Get the ID of the static page with the same slub
    $category_static_page_id = get_page_by_path( $category_slug );

    // If such a page exists, get it
    if ( isset( $category_static_page_id ) ) {
    // Get the static page object
    $category_static_page = get_page( $category_static_page_id );

    // Output page content
    // Apply the usual the_content filters,
    // for usual "nice" formatting
    echo apply_filters( 'the_content', $category_static_page->post_content );
    }
    }
    ?>