1) register multiple CPT
2) set page to archive via option page
3) look over plugin Query Monitor
I have 5 CPT with archive page. Plugin create 5 SQL query, which can be handled by 1.
public function initialise() {
$this->basename = plugin_basename(__FILE__);
if ( $pages = array_unique( array_filter( array_values( (array)$this->get_config() ) ) ) )
$cache_pages = get_posts( array( 'post_type' => 'any', 'numberposts' => -1, 'post__in' => $pages ) );
change get_page to get_post
public function get_archive_page( $slug = null ) {
$page_id = $this->get_archive_page_id( $slug );
return $page_id ? get_post($page_id) : null;
}
]]>
Hi, why you hidding editor? This is best plugin ever for this! ??
//add_action( ‘admin_init’, array( $this, ‘hide_editor’ ), 5 );
<?php
get_header();
$archive_page = post_type_archive_pages()->get_archive_page();
do_blocks( $archive_page ); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ): the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; ?>
get_footer();
?>
]]>Hello, it is compatible with Polylang or WPML plugin? Thank you.
With function like below you can get ID of translated page id
function get_page_language_by_id( $id, $return_original_if_missing = true ) {
if ( function_exists( 'pll_get_post' ) ) {
return ( $ppl_id = pll_get_post( $id ) ) ? $ppl_id : ( ( $return_original_if_missing ) ? $id : '' );
} else if ( function_exists( 'icl_object_id' ) ) {
return icl_object_id( $id, get_post_type( $id ), $return_original_if_missing );
}
return $id;
}
]]>
Hey Darren, When I go to Settings, reading, I set the page I want but it doesn’t show at the top of the post type archive.
This is exactly the functionality I need. I would be willing to pay you to update it.
I’m using Avada them, latest version.
Tom
]]>Hi, does has_archive need to be set to false when you init the post type, or is there an issue my end?
Currently with it set to true, it throws the page out of the page loop and no longer recognises it as a page, but a post type archive… and that causes issues for my sibling navigation.
My current method for solving the same issue that this plugin solves, is to create the archive page as a template also, and select that template for created pages in the wp backend.
]]>How this plugin work with plugins like Yoast? It will take config from page or from “Search Appearance – Content Types”?
]]>