0

I'm using a page called News & Events (permalink: news-events) for my posts page setting in the settings >> reading screen. I want to use blocks on this page and then access them on the index.php and archive.php pages. I'm using the following code to spit out the blocks from that page:

<?php
  $newspage = new WP_Query( 'pagename=news-events' );
  while ( $newspage->have_posts() ) : $newspage->the_post();
      the_content();
  endwhile;
  wp_reset_postdata();
?>

However, that's not working, because of the fact that this page is being hijacked by WordPress as the posts page. If I create a different page and store blocks on it, I can grab them with this code, but I don't like how clunky that is to have two different pages in the dashboard. It's not intuitive for the user. How can I streamline this to use the same page for both?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.