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
- Move Custom Fields on General Settings Page to New Location
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Run wp_kses_decode_entities on atom feed?
- Filtering out the #more anchor link that gets produced by
- Can’t filter wp_get_attachment_link
- Redirect to another page using contact form 7? [closed]
- append to existing parent theme function
- different style sheet for just one page template
- Add Element as a Filter to the_content
- Override the WordPress core function wp_referer_field
- Modify post filter to set custom number of posts per page and exclude child posts
- Make wp_link_pages() suitable for Twitter Bootstrap markup
- How can I add a filter for specific categories on functions.php?
- How to add custom JavaScript in functions?
- Setting a default text for excerpts of a particular category
- How to edit the Tags within the image file URLs?
- 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
- Can’t properly set the_title add_filter to show short_URL
- Add_filter when value is no variable?
- How to retrieve the current post’s generated featured image size?
- How to add_filter html template to middle of content
- (Woocommerce) Order by price when entering specific category
- 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?
- Redefine function arguments before rendering
- Why There Is No “get content by ID” Function
- How to edit classes in body tag?
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- Filter nav menu items HTML tags and wrap inner text with span
- Wp-query Order By problem
- Possible to hook into Media Library preview File column and use a custom image?
- How can I add a class to a nav li depending on URL?
- Create page template via functions.php?
- Create custom function for hero image
- Randomizing wp_tag_cloud() in child theme
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Combine embed_oembed_html and oembed_result
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to append classname to body tag if guest user
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Where do I go to edit this area? [closed]
- Filter to wp_list_authors
- How to add custom li item to wordpress menu
- Replace plugin function with a custom function?
- Add attribute only to first image of every post via functions.php
- Native gallery custom html output
- Different favicon on different pages
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- Functions Filter Question [closed]
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Insert Content Before div#main from the functions.php File
- Add Adsense code between job listings – wp job manager plugin
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- two search forms on the same page
- Function to replace comment’s accented characters before posting
- Replace header image on all other pages but home – URL issue
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- Add a class to post if it has been recently updated
- New checkbox in custom widget isn’t saving data
- Linking Javascript in functions.php file
- how to display a page before the home page
- search form leads to 404
- loginout function customization
- how to add_filter to non hook function
- Function to check if custom page is used by page?
- Changing the text of Upload/Insert on Posts and Pages Screen
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Any adverse effects of adding apply_filters to a function?
- Conditional custom menu?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- Get URLs for AJAX Filter Checkboxes WordPress
- how can I add filter in specfic field in my website?
- How to remove font awesome from loading in wp theme
- How to display an image before title text in menu items
- Adding custom social icons to the social media icon block in the Gutenberg editor?
- Customizing the wp_video_shortcode output with add_filter
- Filter works on last selection but no others
- Overwrite text in a complicated filter hook
- How to replace ACTION url from original wordpress login form?
- Header menu aligned right on all pages except for single-post page [closed]
- How to add HTML into error message