• Resolved OLennox

    (@olennox)


    Hello,

    I was just wondering is it possible to use a different permalink structure for pages and posts? I’m using WordPress as a CMS (pages) that incorporates a news stream (posts). Ideally I’d like the pages to be:

    (a) https://my-site/parent-page/child-page

    and the posts to be:

    (b) https://my-site/news/post-title

    Currently my site is setup using “%postname%” as the custom link so (a) is working well but the posts are all under the root.

    Any advice would be much appreciated! Cheers,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Olennox, I would like to know hwo to do that as well. I wish I could help. Do you know how to move a widget containing posts to a different page than it is already on?

    Thread Starter OLennox

    (@olennox)

    I’ve been poking around with this and it seems that WordPress does this functionality by default. I’m using the custom url:

    /articles/%category%/%postname%

    and my pages are still accessible through a permalink without the “articles” sub-directory whereas my posts are all under “articles”. Seems to be working well
    ———————————————————

    As for your other question:

    I’ve not used “widgets” I’m afraid so I don’t know how they work. I use “The Loop” to render posts inside my pages. For example:

    <?php
    		global $post;
    		$tmp_post = $post;
    		$my_query = get_posts('numberposts=5&category_name=Sport');
    		foreach($my_query as $post) :
    		setup_postdata($post);
    ?>
    
    //generate html using the_content() the_title() etc.
    
    <?php
    		endforeach;
    		$post = $tmp_post;
    ?>

    Note that it is important to store the $post during the loop or else the rest of your page won’t render after this code block.

    Hope it helps,

    Olly

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different Permalink structure for pages and posts?’ is closed to new replies.