You can use the wp
hook and check the global $wp_query
object or any conditional.
add_action( 'wp', 'wpse69369_special_thingy' );
function wpse69369_special_thingy()
{
if (
'special_cpt' === get_post_type()
AND is_singular()
)
return print "Yo World!";
return printf(
'<p>Nothing to see here! Check the object!<br /></p><pre>%s</pre>',
var_export( $GLOBALS['wp_query'], true )
);
}
See: wp
in codex.wordpress.org and wp
in developer.wordpress.org
Related Posts:
- How to add a button to custom post type’s posts-page
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- Why get_next_post_link() or get_previous_post_link() doesn’t return the required links?
- Custom Posts on Different Pages
- Display “Post 2 of 4” on single post page?
- Making pages also serve as taxonomies? Or give full pages to taxonomies?
- Custom Blog Post Listing in Genesis Sample Child Theme
- Trying to edit the single page from a Custom Post
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Allow non-logged in users to see a future post after clicking on a list of future posts
- No Permission to add new Page, Post or CPT with Admin role
- Including link to custom post type in ‘wp_list_pages’ function
- Multiple pages per post (not pagination)
- Can I change my post type to anything and my site still work?
- Display an authors post on a single page only when they are logged in
- How to set the mainpage of a custom post type?
- Render a Post or Page using the correct file
- Am I mixing up the concept of posts pages and categories?
- How to setup different permlalinks for posts and pages?
- Does “Custom Post Type” can have page hierarhy option?
- Best way to fix bad count on All | Mine | Published
- Cannot save pages after migration
- call a function when insert and update a custom post type
- WordPress Contents Migration
- One Post with different content, depending on a Page
- Adding Information To All Posts Screen
- Cannot use pages created on WP
- Different post types arranged on one page
- How to display data with pagaination on backend?
- Hook only specific post type
- How to Associate Posts with Pages
- Why are my wp urls showing page not found?
- How do I hide single category post on my post page
- Create custom PAGE with register_post_type
- Hooking in to an archive page?
- Remove rows in the manage post/page view
- Add custom column in custom post type edit page
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Should I use custom taxonomy or custom post type
- Disable featured image
- How to create custom boxes with text inside?
- How to add post_type=value when editing that post type in the WordPress admin?
- Insert Multiple Post with Same Publish Button
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Open Custom Post Type as PDF
- Using The REST API How To Pull All Custom Posts?
- Validate custom fields before save using WordPress Rest API
- Making a custom help center page
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- create a template page for a post
- Show the same Article Available in Other Categories
- Getting posts under the custom post type ui category
- Page vs Custom Post Types Differences/Issues
- Storing posts from query and accessing later via AJAX call
- If post has custom field then display css-class
- Display only one post each WEEK
- List children on child post
- Restrict custom post type from appearing with ?post_types=
- Show custom post type filtered by category
- Posts are duplicating on wp_post_update
- create parent post using wp_insert_post
- Turn on and off custom post type from admin?
- Missing Posts in Custom Taxonomy List
- Display random posts, but omit the post it is on?
- How do I do this with WordPress? Taxonomies?
- Disable block with taxonomies at post page
- I would like to have different styles for my posts based on the content of each post
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Showing posts from different categories and from custom post type
- Get latest 3 posts from multiple CPT in one query
- Which post does a taxonomy term belongs to?
- List custom taxonomy specific to one custom post type
- Post image in WordPress not appearing on home page
- Exclude pages in archives results
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Meta query for custom post type ignored in main query
- Changing custom type name hides the posts
- Display Ad on Specific Categories
- Make parts of your wordpress website completely built with data from external APIs?
- Hiding posts by other users and non-logged in
- Update Post Meta for a logged in user
- Add custom field to Posts and sort by it
- Add custom post type settings to wordress default posts
- Trouble with CPT Child 404
- Database to page routing API?
- Get related posts of child term of custom post type
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- Adding buttons to Add New Post and Add New Page
- JS innerhtml changing style when using AJAX
- Show titles, date of all posts on single category page
- Assign same parrent Page to pages AND custom post types
- Side effects of Script and Iframe in post
- Allow Static Page Load Dynamic Child Pages
- How to change the post type a theme shows by default?
- Limit number of custom posts per taxonomy
- Set a checkmark in a category based on a URL-parameter
- Several post types on WP Query by tag and taxonomy
- Update postmeta Parent when post_status child change