How to just show first line of content

you could also do something like: function rt_before_after($content) { $replace = “</b>”; $shortcontent = strstr($content, $replace, true).$replace; if ($shortcontent === false) $shortcontent = $content; return $shortcontent; } add_filter(‘the_content’, ‘rt_before_after’); It should look for the first </b> in your content and return everything before that. it then adds the </b> back. The function takes that string … Read more

Site content not showing

It’s possible that someone (something) deleted all of the entries in the wp-posts table. If you are comfortable working with phpMyAdmin, you could take a peek there. It’s also possible that your current theme might be ‘borked’ for some reason. So the advice on changing to one of the ‘twenty’ themes is a good idea. … Read more

Programmatically inserting page breaks

Overriding the default page breaking – with external content parts The page breaking takes place in the WP_Query::setup_postdata() method, when we call the_post() in the loop. The page parts are stored in the global $pages array and fetched with get_the_content() function. This happens all before the the_content filter is applied to the content. We can … Read more

How to change featured content to a different tag in WordPress Twenty Fourteen?

The internal implementation details of that feature are of questionable sanity. If you take a look at said featured-content.php template you would see that it get posts from twentyfourteen_get_featured_posts() however the only thing that function has is twentyfourteen_get_featured_posts filter from quick look at which in peculiar fashion nothing is actually getting hooked because twentyfourteen_setup() declares … Read more

How to add text to comment form #content textarea?

You can filter ‘comment_form_defaults’ to change the textarea. You get an array with the default fields as argument: add_filter( ‘comment_form_defaults’, ‘wpse_67503_textarea_insert’ ); function wpse_67503_textarea_insert( $fields ) { if ( /* your condition */ ) { $fields[‘comment_field’] = str_replace( ‘</textarea>’, ‘EXTRA CONTENT</textarea>’, $fields[‘comment_field’] ); } return $fields; }

Filter post_content before loading in Gutenberg editor

I found that there is no way to change the data which is coming to editor when it is loaded. But it’s possible to replace the data after that. JS: script.js wp.domReady(function () { const newData = window.myNewBlocksData; if (newData) { wp.data.dispatch(‘core/block-editor’).resetBlocks(wp.blocks.parse(newData)); console.log(‘replaced’); } }) PHP: <?php class MyBlocksManipulation { public $prefix = ‘my’; public … Read more

Hide content-box on specific pages (in admin)?

I ended up using userabuser’s answer with a small modification, because global $post doesn’t seem to exist on init. You can instead just query for post in querystring, like so: function remove_editor() { if (isset($_GET[‘post’])) { $id = $_GET[‘post’]; $template = get_post_meta($id, ‘_wp_page_template’, true); if($template == ‘template_name.php’){ remove_post_type_support( ‘page’, ‘editor’ ); } } } add_action(‘init’, … Read more

Remove tinyMCE from admin and replace with textarea

No need to reinvent the wheel – put your editor support back and tweak the settings: function wpse_199918_wp_editor_settings( $settings, $editor_id ) { if ( $editor_id === ‘content’ && get_current_screen()->post_type === ‘custom_post_type’ ) { $settings[‘tinymce’] = false; $settings[‘quicktags’] = false; $settings[‘media_buttons’] = false; } return $settings; } add_filter( ‘wp_editor_settings’, ‘wpse_199918_wp_editor_settings’, 10, 2 );