• tdlui

    (@tdluiamisola)


    Hi Support,

    Can I set a root page for post_type “post”? like what we have on the custom post types?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Havlik

    (@mtekk)

    The root page for the WordPress post type “Post” is set in the WordPress settings. This is found under Settings > Reading, there is an option “Your homepage displays”, set that to “A static page (select below)” and select the desired “Posts page”. The root page concept for CPTs is simply an extension of this “Posts page” idea to custom post types.

    Thread Starter tdlui

    (@tdluiamisola)

    Hi Author,

    Thank you for the quick reply, got it, but is there a way that I can customize the root page that only affects the post_type “post”? I am having a hard time customizing the home.php, I like to use a Page as an archive page of my post.

    Thank you.

    Plugin Author John Havlik

    (@mtekk)

    If you must use a different page for the post root, you can do the following:

    Write a hook into the bcn_before_fill action. In the passed in instance of bcn_breadcrumb_trail set opts['apost_post_root'] to the ID of the page you want to use for the post root page. The following should get you started:

    add_action('bcn_before_fill', 'my_before_fill');
    function my_before_fill($trail)
    {
    $trail->opts['apost_post_root'] = POST_ROOT_PAGE_ID;
    }

    Replace POST_ROOT_PAGE_ID with the ID of the page you want to use for your root page for posts.

    Thread Starter tdlui

    (@tdluiamisola)

    Hi Author,

    Your instruction is clear but it seems like I can’t get it to work, do I need a specific setting for it to work? like Post Hierarchy Display should be check etc.

    
    add_action('bcn_before_fill', 'my_before_fill');
    function my_before_fill($trail) {
    	$trail->opts['apost_post_root'] = 23; //News page ID
    }
    

    Thank you.

    Plugin Author John Havlik

    (@mtekk)

    I forgot that you may need to set $trail->opts['bblog_display'] = true; as well. This is probably best added to the example code I provided. There is an equivalent option in the settings page, but it may be disabled if a static frontpage and a page for posts are not set.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Root page for Post’ is closed to new replies.