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
- Add extra parameters after permalink?
- Calling a Function After New Post Creation for a WordPress Custom Post Type?
- Limit the word count in the post title
- Correct Post Count ( All | Published | Drafts | Pending | Trash ) for Custom Post Type when restricting to view own posts
- get_query_var() not working in pre_get_posts
- Get page by template?
- How to Add Pages Under Custom Post Type URL Structure?
- How to create user personal pages with information from their meta profile fields?
- 960gs different classes on teasers posts
- Structuring a product catalogue in WordPress [closed]
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- Change Post Title Edit Box
- Multiple information using custom post type
- Disable feeds for specific custom post types
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Check Title Unique Or Not and If not error message and dont save
- I am having a problem with form updating/editing WordPress post on the frontend
- remove child post from custom post type archive
- Shortcode for display posts on home page show only one post
- How to Separate CPT From Regular Posts?
- Hooking in to an archive page?
- Remove rows in the manage post/page view
- Making a custom help center page
- Display only one post each WEEK
- Portfolio Page for Classic Posts
- Static page determines as home, but it is not
- Limit the post for differents custom post type in the same wp_query
- WP the_posts() on single-cars.php get category link
- wp_trash_post action hook with custom post type
- Get_the_terms restrict output
- Generate new post from email
- YOAST SEO won’t work on custom post type archive [closed]
- How to add new post using a form to categories when categories are using as menu
- Custom wordpress loop
- Different post title, keywords and description
- how to get options to choose post format in add new post
- Use post in multiple places on a page with multiple posts
- Catch and display error on save_post action
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Using `set_transient()` when saving a custom post type
- Display Parent-Child Posts in specific order by comparing IDs in array
- Add html tot CPT edit screen – no metabox
- How to display custom field in product description?
- In child theme, add CPT to custom taxonomy registered in parent theme
- How to display posts with plugin (advanced custom fields) field groups?
- WordPress – display relationship between blog posts and custom posts
- Add custom template ‘sub-page’ to Custom Post type?
- SEARCH QUERIES – REVERSE OUTPUT
- Is there a way to create a sidebar of bullets
- Get queried object for custom post type count
- edit.php all post not working
- Correct way to register custom post type from external php file?
- How can I get the last 5 element of this tax query?
- How to get the posts that my following users are liked?
- How to insert post 6 times after user register like ask.fm
- How can i order my posts by post type?
- Creating custom post type relationships
- How to mark posts as visited
- How To Loop Through list with Custom Post Types
- Customizing a plugin function using a hook
- erase post excerpt limitation [×]
- Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
- Display all post types together
- Using custom post types within a section of a template
- Pulling in a particular post into a single page based on the post id passed into the code
- Custom My account page and custom page for editing posts
- Get post from custom post type that title is like custom string [closed]