Not sure if this is what you are asking but, I have two custom post types on my website, and the URL to view all posts of a custom post type is edit.php?post_type=mp_shortcodes
If you replace mp_shortcodes with your custom type it might allow you to view all the posts for that custom post type.
Thanks Deviant Media. I tried that, it isn’t working. of course I’m guessing the internal name of the post types. Or maybe there is way to hide them. I’ll have to go browsing tables I think. i’m amazed there isnt a plugin for this
See if either of these two help you.
To use this plugin, create a new folder in your WordPress installation’s wp-content/plugins
directory and name it something like custom-post-type-listing
. Then, create a new PHP file named custom-post-type-listing.php
inside that folder and copy the code above into it.
After activating the plugin through the WordPress admin panel, you’ll see a new menu item named “Custom Post Types” under the “Dashboard” menu.
Don’t install at the same time.
<?php
/*
Plugin Name: Custom Post Type Listing
Plugin URI: https://www.example.com/
Description: A plugin to list all custom post types and their posts.
Version: 1.0
Author: Your Name
Author URI: https://www.example.com/
License: GPL2
*/
// Hook into the admin menu to add a custom page for displaying custom post types
add_action( 'admin_menu', 'cpt_listing_add_menu' );
function cpt_listing_add_menu() {
add_menu_page(
'Custom Post Types',
'Custom Post Types',
'manage_options',
'cpt-listing',
'cpt_listing_page',
'dashicons-admin-post',
25
);
}
// The callback function for rendering the custom post type listing page
function cpt_listing_page() {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
// Output the custom post types and their posts
echo '<div class="wrap">';
echo '<h1>Custom Post Types and Posts</h1>';
foreach ( $post_types as $post_type ) {
echo '<h2>' . esc_html( $post_type->label ) . '</h2>';
$args = array(
'post_type' => $post_type->name,
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
echo '<ul>';
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>' . get_the_title() . ' | ' . esc_html( $post_type->name ) . '</li>';
}
echo '</ul>';
} else {
echo '<p>No posts found.</p>';
}
wp_reset_postdata();
}
echo '</div>';
}
<?php
/*
Plugin Name: Custom Post Type Listing
Plugin URI: https://www.example.com/
Description: A plugin to list all custom post types and their posts.
Version: 1.0
Author: Your Name
Author URI: https://www.example.com/
License: GPL2
*/
// Hook into the admin menu to add a custom page for displaying custom post types
add_action( 'admin_menu', 'cpt_listing_add_menu' );
function cpt_listing_add_menu() {
add_menu_page(
'Custom Post Types',
'Custom Post Types',
'manage_options',
'cpt-listing',
'cpt_listing_page',
'dashicons-admin-post',
25
);
}
// The callback function for rendering the custom post type listing page
function cpt_listing_page() {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
// Output the custom post types and their posts
echo '<div class="wrap">';
echo '<h1>Custom Post Types and Posts</h1>';
foreach ( $post_types as $post_type ) {
echo '<h2>' . esc_html( $post_type->label ) . '</h2>';
$post_type_url = 'edit.php?post_type=' . $post_type->name;
echo '<a href="' . esc_url( $post_type_url ) . '">View All ' . esc_html( $post_type->label ) . '</a><br>';
}
echo '</div>';
}
Did you knock those up? Well done, i will try.
I might leave the “Public = TRUE” off?
Yep, those work great thankyou. Even more interesting if you leave the “Public = TRUE” off
Please note that this plugin will only list custom post types that have the 'public' => true
argument set when they were registered. That is all. If you put false then it will be the opposite.
If you delete it entirely you get both
Well as long as it works for you. Reach out if you need any adjustments.