Site logo

Archived topic

Change Posts to Pages

4 replies · Started by Jacob on February 28, 2023

Viewing posts 1–5 of 5

Hi! I am about to launch new websites and I really would like to use the GP-theme and install two of the templates from the site library. However, I have a problem. I need to use these templates: "Newsroom" and "Info" but I do not want to use "posts". The websites will only use "pages" for SEO-reasoms etc. Is there a workaround so I can use these templates designed for "Posts" but by using "pages" instead? Or do I need to find a complete different theme? I remember there used to be a code to change all posts to pages, can that be used? And can I still use "Categories" in the templates if I use pages instead of posts?

Thank you! I really like GP and it would be very valuable if I can use the templates with Pages. Thanks, Jacob

Not official support. You can make your WP website 100% pages if you wish.

If using existing "posts" on a website, you can use the Post Type Switcher plugin to convert your posts to pages and vice versa.

Newsroom and Info work fine, like any other template / theme for pages or posts.

Thanks Manuel

Hi there,

both those sites have 2 methods of displaying Posts.

1. Standard theme templates that have been customized using GP Block Element - Loop Templates.
This is as seen on the Blog and various Category Archive Pages.

WordPress does not include "Pages" in the main_query by default, so they don't show in blog or archives.
Using the pre_get_posts filter hook you can tell WordPress to include them, here's an example PHP function to do that:

function add_custom_post_types_to_query( $query ) {
    if ( is_archive() && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'post', 'page' ) );
    }
}
add_action( 'pre_get_posts', 'add_custom_post_types_to_query' );

However you would need to consider adding Taxonomies to pages too if you need to.
If you're working with hierarchical page structures then you would not bother here, and method 2 may be more pertinent.

2. GenerateBlocks Query Loop Block
those sites have a static front page that use the GenerateBlocks Query Loop to display posts.
Each of those query loop blocks has a Post Type parameter which by default is set to Posts, you can change this to Pages or any other registered post type. to display those instead.

Each Query Loop can be duplicated, cut and paste to other pages if required.

Thank you so much Manuel and David. I will send these to my developer, Riz, who understands this better. Please do not close the errand in the meantime. Thank you!

You're welcome, and thanks again Manuel.
The topic will remain open

This archived topic is closed to new replies.