Use the second parameter $post
and check $post->post_type
alongside a switch, it’s easier and nicer to work with than several if else if else, etc..
add_filter( 'default_content', 'my_editor_content', 10, 2 );
function my_editor_content( $content, $post ) {
switch( $post->post_type ) {
case 'sources':
$content="your content";
break;
case 'stories':
$content="your content";
break;
case 'pictures':
$content="your content";
break;
default:
$content="your default content";
break;
}
return $content;
}
Hope that helps..
Related Posts:
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- How would go about if I just want a temporary function?
- str_replace function in theme
- Insert image in WordPress with HTML5 tag and caption function
- login_headertitle is deprecated since version 5.2.0
- The_content and Preg_replace in loaded Iframe [closed]
- Problem with images URL after filter applying
- Save_post – Warning: Cannot modify header information
- How to make an If Else on Excerpt Filter
- Shortcode to eliminate and replace with
- child_of not working while searching
- Removing default image size list in Media Box
- How to restrict actions and filters “properly” by conditions
- Modify search function in WordPress (TwentyTwelve)
- syntax for remove_filter in parent theme with class
- How to customize search result page title?
- Removing Unnecessary Text from Admin Menu without CSS
- Problem with extract() with custom shortcode
- Removing title from page
- Hide some items from Screen options in dashboard for products
- Custom function for user register in wp?
- Replace Archive Widget Link Text
- Best way to programatically add “rel” attributes to page and post images
- Remove function or filter
- adding custom classes for tables
- Customizer field value into functions.php variable
- wp_dropdown_categories and custom attribute
- Adding multiple taxonomy filters to functions.php
- Automatically wrap multiple images in div
- Ajax not working properly
- Only let plugin add actions to wp_head & wp_footer on single posts
- Include default functions and methods
- Hard-coding custom menu elements for menu manager
- How can I modify all existing tags while keeping the urls themselves?
- IF Statement on Button to make it complete and “uncomplete” based on user action / click
- Gravity Forms Button Text
- Find resources dynamically loading and change or add to the url
- When sale price is 0.00 show only regular price
- Unable to login using username
- Filtering out the #more anchor link that gets produced by
- How can I add a filter for specific categories on functions.php?
- How to add custom JavaScript in functions?
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Condition OR for current user ID
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- How to retrieve the current post’s generated featured image size?
- Filter an WordPress Function in (general-template.php)
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Where do I store custom functions that call custom page template files?
- Why There Is No “get content by ID” Function
- Wp-query Order By problem
- How can I add a class to a nav li depending on URL?
- Randomizing wp_tag_cloud() in child theme
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Where do I go to edit this area? [closed]
- Filter to wp_list_authors
- Replace plugin function with a custom function?
- Different favicon on different pages
- Add Adsense code between job listings – wp job manager plugin
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- Add a class to post if it has been recently updated
- search form leads to 404
- how to add_filter to non hook function
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- how can I add filter in specfic field in my website?
- Overwrite text in a complicated filter hook
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- custom error message for empty username and password using authenticate filter not working
- Modifying a WordPress Plugin
- CF7 select value get to function and reciept value from function
- Add #primary at the end of navlink permalinks on single posts
- How to add a custom class attribute into code wrapper? [duplicate]
- remove_filter function to unhook twentysixteen parent theme function
- only update titles of single posts
- OOP Switch statement with array as parameter
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- How can I automatically delete comments that contain a URL?
- Appending „read more” to the excerpt conditionally
- How to add class dynamically from templates
- Woocommerce custom calculation function
- Remove all video attachment, both files and post/postmeta from database?
- ACF Filter return value
- Replace image attributes for lazyload plugin on image elements with specific class
- Regex works in regexr, but not if I filter content [closed]
- Retrieve a custom form field modified by a filter
- functions.php filters not applied in AJAX call
- Settings in functions.php used by a plugin
- functions.php / replacing div’s with new ones?
- Can’t change excerpt length and more tag
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- Post variables not displaying correctly in custom function
- Trying to get this function to show below the content
- WordPress Custom wp mail template return full template
- How to Add Extra Text In WordPress Title Before Post Publish
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- post_row_actions filter from parent theme not executing in child theme