How can I pass $post object to ‘save_post’ add_action?
Do: add_action(‘save_post’, ‘my_save_function’, 10, 2); And the $post object will be passed as second argument to your function: function my_save_function($post_ID, $post) {
Do: add_action(‘save_post’, ‘my_save_function’, 10, 2); And the $post object will be passed as second argument to your function: function my_save_function($post_ID, $post) {
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
First of all, make sure you try things out in a development environment on your own PC. This way you can try things out without breaking your live site. The XAMPP package contains everything you need to run it on your own Windows, Mac, Linux or Solaris machine. Then, enable debugging mode by setting WP_DEBUG … Read more
Are you referring to the Visual or the HTML editor or both? According to jQuery Set Cursor Position in Text Area it is possible to set the cursor position for a textarea element. That is good news, as AFAIK the WordPress HTML editor is using a textarea element. The WordPress Visual editor in difference is … Read more
@Jack Slingerland, There are a few plugins that do this but the only one I that has been updated recently is Power Code Editor. At a recent WordCamp Matt mentioned that a new built in theme editor with a trash bin and revisions is on the road map but I have not heard it mentioned … Read more
After you post your content, WordPress will pass the_content() function through a number of filtering function’s. There are four of them, wptexturize(), convert_smilies(), convert_chars(), and wpautop(). All of these are defined in wp-includes/formatting.php and are referenced in wp-includes/default-filters.php. To remove these filtering functions you can disable them by putting this in your functions.php theme file: … Read more
Right now there are no hooks to do that from a plugin and the function that makes the search query itself is not pluggable which means that the only way to achieve that is to hack core files. Currently there is an open Trac Ticket asking for some kind of hook.
It really depends on what you’re trying to do. First of all, you should never edit core WordPress files. Any changes you make will be lost if and when you upgrade, so if you want to change functionality, use a plug-in. If you want to change the way your site displays, change the theme. In … Read more
You can postpone the wp_autop filter. WordPress has this filter enabled by default. And it is processing before the shortcode output. remove_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘wpautop’ , 12); Add this to your functions.php and check if the problem persist! See a similar problem here: stray <p> elements
It depends on who the comments are for, are they for the administrators and editors or are they also for the contributors? I’ve setup a system, somewhat elaborate, which handles some of what you’re asking, however the easiest way to achieve something like this is by using custom fields. In particular, a custom metabox with … Read more