I believe checking in_the_loop will work for the main query:
function custom_title( $title ) {
global $post;
$text="Extra text: ";
if ( get_post_type( $post->ID ) == 'custom_post_type' && in_the_loop() ){
return $text . $title;
}
else {
return $title;
}
}
add_filter( 'the_title', array($this, 'custom_title' ) );
Related Posts:
- Prevent trash/delete action on specific post types
- How to add custom content template part for a custom post type on main query using a plugin
- Loading custom page template via plugin
- Why The Init Hook For Custom Post Types
- wordpress plugin error handling
- How to get term link that crosses different custom post types?
- register_taxonomy with multiple object type and update_count_callback
- How often do you need to register_post_type?
- Where to put archive-{post-type}.php
- How to use a dedicated template for the Custom Post Type from a plugin?
- Determine which template-{slug}.php is being loaded
- Use a textarea for a custom post type
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- How do I include drag-and-drop in a plugin?
- How could I create a ‘private comments’ section on a custom post type?
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- Issue with pre_get_posts on custom post type archive pages
- Get rewrite slug of custom post type in template
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Hook to override title, image and content
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- No posts found – Custom Post Type show_ui
- WordPress multiple custom post types capability conflict in a single menu
- Add Custom Post type menu to another menu in specific location
- Set a CPT slug as a base name for all the taxonomies
- A custom post type in another post type
- Problems wp_insert_post and save_posts filter
- wordpress remove views from action links in a custom post
- Custom post type’s extra fields – how to handle?
- Send a conditional email notification when a custom field value changes in Post Type
- how to set a WP Plugin’s url
- Getting 400 Bad Request on AJAX Call
- Main query not querying any posts in custom taxonomy template
- detect your custom post type in WordPress
- Option page’s form doesn’t work
- How can I include active content in a custom post type?
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- ajax response not recieving
- Add post type pages with plugin
- Create a select metabox that the user can pupolate?
- How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop
- CPT to installable Plugin
- Most viewed post of custom post type
- filter the_content, custom post type, and wp_query
- Fill custom fields when saving custom post types
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Custom post type page with parameter
- Custom post type category link redirecting to 404 page
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Translate website without duplicate custom post
- Custom post category name showing empty
- How to show the post which checkbox is not selected
- Is it possible to get the specific content on the search page?
- Get next and prev item from custom WP_Query and Custom Post Type
- Replace Content of Sidebar on Custom Post Type
- How add Filter by Tags and by categories to custom post type in Gutenberg block
- How to upload an image to a custom post type
- Error 404 change permalink term custom term taxonomy
- Show a custom post title in another custom post type in Meta box
- Register custom_post_type from static function
- I have a random letter appearing before my content. Where to start looking for the cause?
- How to select meta key in custom database query
- Apply a custom Template to a Custom Post Type from within a plugin
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Restrict Custom Post Type to One Item
- How to seperate posts by categories?
- How to Use A Custom Post Type as Taxonomy for Another Custom Post Type
- Widget area for individual posts (custom post type)?
- Add an array as post content dynamically
- How can I load Template file from wordpress plugin
- Which File Populating CPTs in Slug URL
- Front End users account with lots of user Roles (not Woocommerce)
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- Custom post type that lets users create a set of posts?
- Not Able to List CPT Based on Taxonomy Term
- How to reset HTML filter input fields on CPT list page?
- Foreach in get_post_types to apply a different filter per post type
- How to develop custom URL redirection
- In WordPress do I create tables for my plugin or do I create custom post types for a Student and Classes Registration system?
- Execute code only after user clicks ‘update’ button for CPT being edited
- Simple renaming my custom post type set with a plugin doesn’t work?
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Display custom post type archive on page.php template
- Associate custom categories to different user IDs
- How to avoid hardcoded text in a custom page template?
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Add category slug as class attribute in a link array
- How to use get_sidebar in plugin folder?
- Custom post types working in functions.php but not in plugin
- Resources to learn OOP for WordPress plugins, custom post types, etc
- How to create an upload page (front side)
- How to dynamically register custom post type
- How to filter custom post data with AJAX?
- How to consume external API from WordPress post editor and display the response data in the custom field?
- Display box in sidebar of custom post type
- Remove `View post` Text