Multiple editors on single page wordpress - wordpress

After lot of research i got the answer for achieving multiple editors on single page in WordPress that it can be done using tinymce.But i am confused where exactly i need to implement the coding part of tinymce in my custom theme
Thank You

Just add wp_editor function in your custom theme files.
Here is example:
wp_editor( $post_content, $custom_id, $settings = array() );

Related

Is there a way to change the default template for all posts in wordpress?

I am creating posts in wordpress programmatically using php. Is there a way to change the post attributes template either programmatically or using the admin panel for all posts? I would like the default to be Product details as you see in the picture below.
Any help appreciated. Thanks.
after creating post programmatically assign page template.
update_post_meta( $post_id, '_wp_page_template', 'page-template.php' );

What is the right place for reusable render functions in WordPress theme?

Let's say I have a reusable peace of HTML used on different pages in my theme.
In order to not duplicate myself I want to put this peace of HTML into some place and reuse it later. And because it has some parameters (needed for rendering) - it should be a function.
It seems to me that I cannot use get_template_part function because I want to pass some parameters into the render function.
functions.php feels more like a place for low level theme functionality.
What is the right place for render functions in WordPress?
UPD I've just found that in _s theme that I am using as a base code for my theme they have inc/template-tags.php. It feels like a good place. Is it the right way?
check codex set_query_var and get_query_var
In main template
set_query_var('customer_name', $customer_name);
get_template_part( $slug, $name );
template part retrieve it as
$customer_name= get_query_var( 'customer_name', 1 );
echo $customer_name;
Ok so in _s theme they suggest:
Custom template tags in inc/template-tags.php that keep your templates clean and neat and prevent code duplication.
Seems like a good place was found :)

Wordpress plugin shortscodes in other plugins?

I'm developing a plugin that creates custom wordpress pages, however I ran into a problem when trying to get shortcodes from other plugins to integrate into my plugin, well more like I couldn't find any info on it.
For example if someone uses my custom page builder and adds a short code [gallery] that is associated with an enabled plugin, I want the shortcode to do it's thing.
Could anyone point me in the right direction for this?
Try wordpress
http://wordpress.org/plugins/synved-shortcodes/
while this plugin let's you integrate shortcodes on every wordpress page , I suppose that you issue is with wordpress functions.php file where you can have a look at , with this plugin installed !
You can check if a shortcode exist before printing it with the function shortcode_exists() (https://codex.wordpress.org/Function_Reference/shortcode_exists)
Example:
<?php
if ( shortcode_exists( 'gallery' ) ) {
// The [gallery] short code exists.
}
?>
Then, if it exist and you want to print that shortcode with PHP code you should use do_shortcode() function (https://developer.wordpress.org/reference/functions/do_shortcode/)
Example:
<?php echo do_shortcode('[gallery]); ?>
Always use in WordPress's in-built
the_content
hook to print your custom page content.
WordPress by default process all shortcodes before outputting any stuff from this hook.
More info can be found here: https://codex.wordpress.org/Function_Reference/the_content

How to use Wordpress Text Editor in a custom plugin

How can we use default wordpress text editor for my wordpress plugin.Any suggections please?
The WordPress Text editor is an application of the TinyMCE Editor. You can utilize the files located in wp_includes/js/tinymce and create an instance of the editor on your own, according to the documentation.
Check out this article for example instructions:
http://wordpress.org/support/topic/how-i-can-use-tinymce-for-my-own-plugin
As of Wordpress 3.3 the_editor has deprecated in favor of wp_editor. wp_editor uses the new media uploader and takes advantage of all the new features of Wordpress 3.5.x Documentation here: http://codex.wordpress.org/Function_Reference/wp_editor
A very good example of how to use it can be found at Wptuts+ here: http://wp.tutsplus.com/articles/tips-articles/quick-tip-using-wp_editor/
very easy try this code
it's working
wp_editor( $distribution, 'distribution', array( 'theme_advanced_buttons1' => 'bold, italic, ul, pH, pH_min', "media_buttons" => true, "textarea_rows" => 8, "tabindex" => 4 ) );
Very easy:
<?php wp_editor( $content, $editor_id ); ?>
This will generate a lot of html tags. But the one you will be interested in is the textarea with its name set to $editor_id. So when the form is submitted, you can save that content.
You can find more info here: https://codex.wordpress.org/Function_Reference/wp_editor

How to enable tinyMCE rich text editor for post Comments in WordPress?

I would love to kinda replicate WordPress post/page text editor (Admin panel) in comments section. That's how site users will be able to format text easily. A good example of what I actually need can be found here at StackOverflow when someone is about to Ask Question.
In your functions.php, add the following snippet:
add_filter( 'comment_form_defaults', 'tinymce_comment_4265340' );
function tinymce_comment_4265340 ( $args ) {
ob_start();
wp_editor( '', 'comment', array('tinymce') );
$args['comment_field'] = ob_get_clean();
return $args;
}
It's working on WordPress 3.5 and Twenty Twelve theme.
The TinyMCEComment WordPress plugin could help you out. It uses the internal TinyMCE editor (bundled in WordPress 2.0 and up).
Try this tutorial. It worked for me. The above answer might add TinyMCE to the reply section. The tutorial shows how to fix that.

Resources