Custom Post Type New Idiot
-
I do apologise, but I am stumped.
I created a CPT, it works. Kinda… I created a challenge, that users should log their amount of arrows shot for the day/session for the user. I am comfortable with MySQL and most forms of SQL, but brand new to WordPress plugin development.
I added a Custom Link to my challenges and I can see the challenges I loaded. When I click on one of those it redirects to Page Not Found.
Is there something I should add or something I am missing? I have gone through various video tutorials and web tutorials to no avail.
defined( 'ABSPATH' ) or die("Mary had a little lamb...");if (class_exists('NuLogPlugin')){
$NuLogPlugin = new NuLogPlugin();
}class NuLogPlugin
{
function __construct() {
add_action('init', array( $this, 'custom_post_type' ) );
}function activate(){
flush_rewrite_rules();
$this->custom_post_type();
}function deactivate()
{
//Flush rewrite rules
flush_rewrite_rules();
}function uninstall()
{
//delete CPT
}function custom_post_type() {
$labels = array(
'name' => __( 'Challenges', 'NuLog' ),
'singular_name' => __( 'Challenge', 'NuLog' ),
'add_new' => __( 'New Challenge', 'NuLog' ),
'add_new_item' => __( 'Add New Challenge', 'NuLog' ),
'edit_item' => __( 'Edit Challenge', 'NuLog' ),
'new_item' => __( 'New Challenge', 'NuLog' ),
'view_item' => __( 'View Challenge', 'NuLog' ),
'search_items' => __( 'Search Challenge', 'NuLog' ),
'not_found' => __( 'No Challenge Found', 'NuLog' ),
'not_found_in_trash' => __( 'No Challenge found in Trash', 'NuLog' ),
);$args = array(
'labels' => $labels,
'has_archive' => true,
'public' => true,
'hierarchical' => false,
'supports' => array(
'title',
'editor',
'distance',
'custom-fields',
'thumbnail',
'page-attributes'
),//'taxonomies' => 'category',
//'rewrite' => array( 'slug' => 'Challenge' ),
//'show_in_rest' => true
);register_post_type('Challenge', $args);
//register_post_type('challenge',['public' => true,'label' => "Challenge"]);
}
}// activation
register_activation_hook( __FILE__, array($NuLogPlugin,"activate" ));// deactivation
register_deactivation_hook( __FILE__, array($NuLogPlugin,"deactivate" ));// uninstall
//register_uninstall_hook(__FILE__, array($NuLogPlugin,"uninstall" ));
The blog I need help with is: (visible only to logged in users)
-
Hi there!
Custom code is not available on WordPress.com so I assume you’re talking about a WordPress site hosted elsewhere – we are not able to help with those.
Because WordPress.com and WordPress.org are two entirely separate entities, we cannot access files or data for sites that are hosted elsewhere, so WordPress.com staff can only assist with sites that are hosted on our servers. You can read more about the differences between WordPress.org software and WordPress.com here:
https://wordpress.com/support/com-vs-org/You can look for help at the community forums here: https://wordpress.org/support/forums/
http://wordpress.org/support/ is also a great resource for sites using the open-source WordPress.org software.
- The topic ‘Custom Post Type New Idiot’ is closed to new replies.