I think you’re looking for the “conditional” get_post_type.
In your case it would be:
function orderby_post_title_int( $orderby, $query ) {
if ( 'chart' == get_post_type() ) {
return '(wp_posts.post_title+0) ASC';
}
return $orderby;
}
Or you could insert the conditional in your original function, which you know was working?
(Note if this is a custom post type archive, you’d use the is_post_type_archive() conditional instead.)
Related Posts:
- remove custom post type permalink
- Media library – Limit images to custom post type
- Sort search results by post type
- How to remove Filters from post admin page?
- Custom sortable columns ordered by meta-value?
- How to change “Draft” string for status of custom post type to “Unavailable”?
- How can I filter posts by post_parent in the admin?
- Filter for “get_post_type_archive_link()”
- Filter by custom Field for Custom post type Admin Listing
- Most efficient way to search for values from CPT in Post content
- Remove wpautop from all posts/pages except my custom post type
- Remove date and category filters when editing custom post types
- Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts
- Title_save_pre – Simple problem that u know for sure
- Image size filtering in Media uploader according to custom post type
- wp_query and comment_parent – select only posts with top level comments
- Highlight nav menu terms
- Want to filter only parent post in admin area
- Hooking into wp_export filter for custom post type [closed]
- Custom Post Row Actions
- Filters post in admin with dropdown select, custom post type
- Admin List Dynamic Heading
- How can I add a column in the wp_list_table of the admin area?
- How to filter the description of a custom post type
- Filter home_url for custom post type
- Add Content Exclusively to a Custom Post Type Feed
- Add html to cpt main page / admin edit.php
- register_taxonomy and register_post_type does not work [closed]
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- Filtering WP_Query
- Displaying custom taxonomy in the admin list of a custom post type
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- Filter term taxonomy metabox in custom post type
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Sort and filter custom post type posts by custom taxonomy
- Versioned Custom Post Type (Not the same as revisions)
- Loop filtering Custom Post Types and/or Categories
- the_content filter on some post types only not working
- Custom filter function not working with Custom post type
- Filter Posts from the Main Query
- How to use manage_$post_type_posts_columns with underscore in post type?
- How does the filter post_updated_messages work?
- Search filter triggered & sort by custom post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- wp_insert_post wrong post type [closed]
- How can I remove filters from custom post types?
- REST filters only firing when I have a param set
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to filter url on post submission?
- Change Custom Post Type singular_name through function/filter
- Modify a plugin function output from another plugin
- Custom Taxonomy Filter Issues
- show most viewed posts of last days by link?
- Filter search posts by post meta?
- Modifying search results based on post_type
- Remove filter and view options from custom post type edit screen
- conditional filter
- Is there any filter to add a custom attribute to the tag in admin panel?
- Store a value in global scope after init hook is fired
- Filter in Custom post type to find the parent post
- Dynamic page for nav items used as filters
- Filter posts by their related field’s custom field
- How can I add image sizes for a specific custom post type?
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- pricefilter without WooCommerce
- Output all terms slugs for a loop filter
- Insert custom taxonomy into category query
- filter rest api post by a acf filed
- Group Custom Posts Types in a Relation field of ACF
- Help Adding filter to Add Media button for custom post type
- Apply pre_get_posts to specific custom post type in the admin area
- how it’s possible to show from a post of a custom post type the taxonomy/terms?
- Enable shortcodes on custom post type
- Filter between Custom Posts depending on meta_value
- Highlight a Post on archive page if it has a new comment?
- Creating adminable dynamic filtering on custom post type
- Menu disappears with custom post type link
- Filter wp_dropdown_categories Per Post Type
- Custom post type with Filter and Page Nav
- Converting a checkbox filter for custom fields to a dropdown
- add current-menu-item to multiple custom post types
- using ACF datepicker to filter posts on a page
- Hook only specific post type
- Diffrent search templates for different post types
- How to filter posts by categories?
- How do I filter a custom post type loop by a field?
- A to Z list for custom post types
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Trying to set up a range filter for related custom post types
- Add post id to url instead of WordPress default -2 suffix
- Custom post type template not loading from plugin
- Modify wp_title for custom post types using custom fields data?