You only create an instance of your class on admin requests, so your CPT doesn’t exist on front end requests. Instead of:
if( is_admin() )
$cpt = new CPT('cpt_child');
create the instance on all requests:
$cpt = new CPT('cpt_child');
Related Posts:
- Custom post type archive sorted and grouped by date in post meta field
- How to enqueue scripts on custom post add/edit pages?
- remove custom post type permalink
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Custom Post Type Settings page, choose page to display archive
- Adding a menu item for a Custom Post Archive
- Adding custom post type archives to a WordPress menu
- Custom Post Type Template – Archive
- How to change “Draft” string for status of custom post type to “Unavailable”?
- How do you create an archive for a custom post type from a plugin?
- Custom Post Type Archives by Date with Custom Permalink
- Custom post type save_post action not firing
- How to List All Custom Post Types Names (Not Posts)
- Change title in head on Archive page
- What are the advantages of using a custom post type archive?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Custom Post Type archive as front page
- I can’t set meta_key in my custom post type query
- WordPress Custom Shortcode Conflicting with Media Library
- Adding Sticky functionality to Custom Post Type Archives
- Adding custom post types to archive.php
- Archive page for taxonomy of custom post type
- WordPress custom post action hook
- archive-{$post_type}.php not loading. instead the default archive.php loads
- How to make an archive page displaying posts in a date range
- Categories and Tags not working!
- Using pre_get_posts to Filter Posts
- Remove “Get Shortlink” button in admin of custom post type
- How to get Custom Post ID by adding filter to child theme’s function
- WordPress custom post type archive with description
- Display Next/Prev when looping Custom post-types archive?
- Add custom post type archives to search results?
- Archive page for custom post type not working
- Editable content on a Custom Archive page
- Second Custom Post Type Archive
- How can I filter by taxonomy on a custom post type’s page?
- An empty Custom Post Type Archive page returns 404 in WP 3.1
- CPT Archive with core Category
- get the custom post type title/name
- Custom post types and tag archive pages/permalink structure issue
- Displaying Page as Custom Post type landing Page
- Displaying custom taxonomy in the admin list of a custom post type
- WordPress post_where & posts_join not working only for custom post type
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- CPT archive admin menu label
- Custom post type archive page blank
- Content Editable CPT Archive?
- Paginate_links in custom post type template
- Using preg_replace to filter custom textarea
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- How to hyperlink content from archive page with custom post-type
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- Running a wordpress action when a custom post type term (taxonomy category) is changed
- sort CPT on Custom Taxonomy Archive page
- CPT Archive pre_get_posts not working?
- Removed custom post type archive page shows blog page
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- CPT archive page – show one post from each taxonomy term
- Create a Custom Path to Archive
- Specifying a template for custom post type pages
- How to set a ‘page’ as parent of a custom post type?
- Archive page of CPT’s custom Taxonomy
- 2 Custom Post Types In 1 Archive Page?
- Custom post type archive URLs with a single taxonomy
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- Different number posts per page based on custom post type term id
- How to change URL for custom post type archive?
- Displaying all posts by category and showing content on click
- ACF Pro Accessing fields on a Custom Post Type
- publish_post action callback not executed, why?
- Tell wordpress to show a single page instead of an archive page
- How to store additional data that is related to core data
- Custom post pagination not working
- Custom post type post_type_link gives “page not found” on any other custom post type
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Rewriting archive page slug to be different than custom post type slug
- Site loads very slow for archive custom post type page
- Remove the “View” Link in Post edit Admin
- CPT archive as home page
- Have two (permalinks) urls for a same custom post type
- How to display the FAQ Archive page in my menu
- How can I set up the URL for a category archive for a custom post type?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- Archive Page Pagination not working
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- Create a Page Templete to Display Table Of Content for Custom Taxonomies
- Create action running on trashed_post hook to modify post_meta value
- has_archive for default post type
- Custom post type functions.php if statement on action
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Show custom post type on post category page doesn’t work / breaks navigation
- On archive.php show loop for child categories if they exist or posts if they don’t, on custom post type
- Pagination not working on custom post type archive
- Best practice to display a list/archive of Custom Posts in a Page Template
- Archive pagination – second page shows exactly the same posts