• Resolved L4SN

    (@l4sn)


    Hello,

    I am looking at switching to Pods from CPTUI in hopes of speeding up the load time of my site, however one of the biggest issues I will have is the number of custom post types I will be creating.

    I will need to have a separate submenu or landing page from the admin menu to list all of the custom post types. Having them all in the admin menu is simply not feasible.

    Any help would be greatly appreciated.

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    You can nest CPT made with Pods under other menu items in WP admin.

    When you edit a Pod (CPT/Taxonomy/etc) please go to the “Admin UI” tab and you can add the parent menu ID to nest it.

    Thread Starter L4SN

    (@l4sn)

    I’m assuming it would probably be best to create a custom parent link?

    Thread Starter L4SN

    (@l4sn)

    And is there a way to list all of your pods custom post types on one admin page so that my writers can search through the list quickly to find what they want?

    • This reply was modified 5 years, 3 months ago by L4SN.
    Thread Starter L4SN

    (@l4sn)

    I’ve set up a plugin with this code to try and list all of the pods in one spot but I got a fatal error with ‘foreach’.

    Here is the code –

    <?php
    /*
    Plugin Name: Pods listing page
    
    */
    
    function l4sn_pods_admin_page() {
    	?>
    	<div class="wrap">
    		<h1><?php echo get_admin_page_title(); ?></h1>
    
    		<h2>Player List</h2>
    		<ul>
    			<?php
    			$pod = get_post_type();
    			foreach ( $pod_types_found as $pod_type )  {
    				printf(
    					'<li><a href="%s">%s</a>',
    					admin_url( 'edit.php?post_type=' . $type ),
    					$type
    				);
    			}
    			?>
    		</ul>
    
    		
    	</div>
    <?php
    }
    
    • This reply was modified 5 years, 3 months ago by L4SN.
    • This reply was modified 5 years, 3 months ago by L4SN.
    Plugin Author Jory Hogeveen

    (@keraweb)

    I’ve set up a plugin with this code to try and list all of the pods in one spot but I got a fatal error with ‘foreach’.

    That is because this code is incorrect. $pod_types_found is not declared yet.
    You can use the WordPress function get_post_types() for that. See WP Codex: https://codex.www.ads-software.com/Function_Reference/get_post_types

    I’m assuming it would probably be best to create a custom parent link?

    You can use any admin menu parent for that so that is up to you!
    This needs to be the parent menu slug. See WP documentation: https://developer.www.ads-software.com/reference/functions/add_submenu_page/

    Thread Starter L4SN

    (@l4sn)

    You can use any admin menu parent for that so that is up to you!
    This needs to be the parent menu slug. See WP documentation: https://developer.www.ads-software.com/reference/functions/add_submenu_page/

    The plugin I’m setting up provides a clean link and landing page so that eliminates that issue.

    That is because this code is incorrect. $pod_types_found is not declared yet.
    You can use the WordPress function get_post_types() for that. See WP Codex: https://codex.www.ads-software.com/Function_Reference/get_post_types

    Thanks!

    I’m slowly getting there… lol

    But I appreciate the help, and I’ll probably be back with more questions.

    Thread Starter L4SN

    (@l4sn)

    Ok, I have it set up with a link in the admin menu (sidebar) that opens a landing page to edit post types.

    <?php
    /*
    Plugin Name: Pods listing page
    */
    
    function l4sn_pods_admin_page() {
    	?>
    	<div class="wrap">
    		<h1><?php echo get_admin_page_title(); ?></h1>
    
    		<h2>Player List</h2>
    		<ul>
    			<?php
    			$pod = get_post_type($pod);
    			foreach ( get_post_types() as $pod ) 
                printf (
    				'<li><a href="%s">%s</a>',
    				admin_url( 'edit.php?post_type=' . $pod ), $pod);
    			?>
    		</ul>
    
    		
    	</div>
    <?php
    }
    
    function l4sn_pods_menu_setup() {
    	add_menu_page( 'Player List', 'Player List', 'edit_published_posts', 'l4sn_pods', 'l4sn_pods_admin_page' );
    }
    add_action( 'admin_menu', 'l4sn_pods_menu_setup' );

    The only problem I have here is that it is listing everything that is linkable from the nave menu instead of just the custom post types from Pods.

    Any help sorting that would be greatly appreciated.

    • This reply was modified 5 years, 3 months ago by L4SN.
    Plugin Author Jory Hogeveen

    (@keraweb)

    $pod = get_post_type($pod); is incorrect PHP code. $pod is not declared yet so cannot be passed as a variable. Besides, you can remove this line completely.

    get_post_types() doesn’t know what plugin created the post types since it’s a WordPress function, not Pods.
    https://codex.www.ads-software.com/Function_Reference/get_post_types
    One option is to filter on the _builtin parameter like so: get_post_types( array( '_builtin' => false ) ). Though this will return all CPT that aren’t built in with WordPress (so also CPT made by other plugins).

    Also, see load_pods in our documentation: https://pods.io/docs/code/pods-api/load-pods/
    You’ll also find an example on that page.

    Hope this helps!

    Thanks, Jory

    Thread Starter L4SN

    (@l4sn)

    That got me straightened out!

    Thanks!

    Here’s the code in case anyone else would like to be able to utilize it –

    <?php
    /*
    Plugin Name: Pods listing page
    */
    
    function pods_admin_page() {
    	?>
    	<div class="wrap">
    		<h1><?php echo get_admin_page_title(); ?></h1>
    
    		<h2>Player List</h2>
    		<ul>
    			<?php
    			$post_type = get_post_types( array( '_builtin' => false ) );
    			foreach ( $post_type as $post_type  ) 
                printf (
    				'<li><a href="%s">%s</a>',
    				admin_url( 'edit.php?post_type=' . $post_type ), $post_type);
    			?>
    		</ul>
    
    		
    	</div>
    <?php
    }
    
    function pods_menu_setup() {
    	add_menu_page( 'Player List', 'Player List', 'edit_published_posts', 'pods', 'pods_admin_page' );
    }
    add_action( 'admin_menu', 'pods_menu_setup' );

    Thanks again for the help!

    • This reply was modified 5 years, 3 months ago by L4SN.
    • This reply was modified 5 years, 3 months ago by L4SN.
    Plugin Author Jory Hogeveen

    (@keraweb)

    You’re welcome! The best way to say thanks is to leave a 5 star review at https://www.ads-software.com/plugins/pods/ and (if you’re feeling especially generous) become a Friend of Pods at https://friends.pods.io/

    Good luck with your project!

    Cheers, Jory

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Submenu for Pods’ is closed to new replies.