How to create WP Editor using javascript

Thanks to Jacob Peattie’s comment I can answer this using JS only. Actually we did something similar, but prior 4.8 and it wasn’t this easy, so we did use wp_editor() in the end. But now, you can do so using wp.editor object in JavaScript. There are 3 main functions wp.editor.initialize = function( id, settings ) … Read more

Insert Custom HTML After Shortcode

I wonder if you could override the [rev_slider] with this kind of wrapper: add_shortcode( ‘rev_slider’, function( $atts = array(), $content=”” ) { $html=””; // Your custom banner HTML $banner=”<div id=”bannerHTML”><!– banner HTML goes here –></div>”; // Append your banner HTML to the revslider’s output if( function_exists( ‘rev_slider_shortcode’ ) ) $html = rev_slider_shortcode( $atts, $content ) … Read more

Proper way to get page content

Just to clarify: You mixed two things here. qTranslate stores the different languages in the same post. If you call get_content(), $post->content or an other direct query, you will get the whole content with all different languages from the database. What qTranslates do, it creates a filter-hook which is attached to the_content hook. If somebody … Read more

Why is javascript allowed in my post content?

If you have the unfiltered_html capability then you can use JS. Admins and editors have this capability by default. Personally I use a plugin for fine control of my users’ capabilities, but you can make this change easily in code: $role = get_role( ‘administrator’ ); $role->remove_cap( ‘unfiltered_html’ ); $role = get_role( ‘editor’ ); $role->remove_cap( ‘unfiltered_html’ … Read more

post_content with line breaks

I believe this should work: $getPost = get_the_content(); $postwithbreaks = wpautop( $getPost, true/false ); echo $postwithbreaks; The second argument in wpautop can be up to you whether it’s true of false, see the link below. It is described as follows: (bool) (Optional) If set, this will convert all remaining line breaks after paragraphing. Line breaks … Read more

Get post content from outside the loop

You can use get_page() to return the $post object of a static page: $page_id = 302; $page_object = get_page( $page_id ); echo $page_object->post_content; Edit Similarly, you can use get_post() to return the $post object of a post: $post_id = 302; $post_object = get_post( $post_id ); echo $post_object->post_content;

When is the ‘post_content_filtered’ column in database cleared by WordPress?

Every post update in WordPress is handled by the wp_update_post function. This function has some defaults, and for post_content_filtered the default value is ” (empty string). Once the defaults are merged with args passed to function via wp_parse_args it means that every time a post is updated and post_content_filtered is not explicitly passed, it is … Read more