I am learning to register the custom post type using the plugin but got too confused, following are my queries:
So, could anyone make me clear on this topic?
I am learning to register the custom post type using the plugin but got too confused, following are my queries:
So, could anyone make me clear on this topic?
Welcome to WPSE.
The way you are describing your problem implies, that you are mixing apples with bananas in my opinion.
There are a couple of things, we should distinguish in order to get to the bottom of your problem.
Custom post types in general:
First, there is no such thing as "THE" Custom Post Type.
Custom Post Types are a core functionality, build into WordPress itself. It can be considered as a way to expand the range of different content. Another word often used in this context is "archetype" (not in WordPress, but for example in HUGO).
Second, there is no such thing as "The" plugin. Yes, there is a plugin called "Custom Post Types", which is what you are probably using. But that doesn't mean, that this is the only plugin, which you can use. Other plugins and also themes make use of this functionality too.
Out of the box, WordPress comes with 2 post types, posts and pages. When you create a new post type, let's say "books", then the post gets stored in the same database table as posts and pages. Metadata, like custom fields are extracted/split and stored in a different table.
The deactivation hook is ment to do some cleanup work, after a plugin deactivation.
In order to flush the rewrite rules, all you have to do is:
Step 1: In the main admin menu find "Settings > Permalinks". Step 2: Scroll down if needed and click "Save Changes". Step 3: Rewrite rules and permalinks are flushed.
It is the same as including flush_rewrite_rules() in you code.
This is a thing, which you only do once, after a plugin or theme activation, which affects the permalinks structure.
When you just deactivate a plugin with a post type, and the custom posts are still in the database, then it might be possible, that your theme is picking up the title and the permalink from these posts until you have flushed the rewrite rules again.
It might be possible, that PHP still has the pages in memory, but after clearing your cache and browser history, that should no longer be the case.
However, in order to proper help in this forum, I'd highly recommend you to read the help guidelines on how to get proper help.
It is very likely, that your theme is still picking up the title and the permalink, based on the official template hierarchy.
You are unclear with describing your problem.
What kind of plugin are you using?
Have you written any code yourself?
Please be more specific.