Tag Info

Hot answers tagged

37

Welcome to WordPress stack exchange! Just yesterday I created WP-Markdown, which enables Markdown on your posts. It also provides the same interface as this website (the toolbar, and live preview) - however, currently only for comments and bbPress forums (if enabled). That said, (since it would be straightforward to do), I am planning on adding an option ...


26

here's what we did yesterday on a client site that we were having this exact problem with... I created a quick filter as a plugin and activated it. <?php /* Plugin Name: Image P tag remover Description: Plugin to remove p tags from around images in content outputting, after WP autop filter has added them. (oh the irony) Version: 1.0 Author: Fublo Ltd ...


13

If you pass nothing for the supports argument, the default settings of 'title', 'editor' is used (where "nothing" is anything that is empty()). However, just like you can add support for something after registering the post type with add_post_type_support( $post_type, $feature ), you can remove support for something by calling remove_post_type_support( ...


12

Basically you need to make WordPress treat img like block-level element for the purpose of formatting. Such elements are hardcoded in wpautop() and list is unfortunately not filtered. What I would do is: Fork wpautop() under different name. Add img to regexp in $allblocks variable. Remove wpautop from the_content filter. Add your forked version to ...


12

I recently got this working. You should search and replace metaname with your meta box name. The key to maintaining formatting was using wpautop(); when saving the data. add_action( 'add_meta_boxes', 'add_metaname_box'); add_action( 'save_post', 'metaname_save'); function add_metaname_box() { add_meta_box( 'metaname_id', __( 'metaname ...


10

Hazarding a guess at what you really mean, I suppose you mean something like this is happening: If that is what you're referring to, that's because your theme has an editor-style.css stylesheet that's getting used in the visual editor. Somewhere inside that stylesheet is something like this: html .mceContentBody { max-width:640px; } Removing that ...


9

If you end goal is to add text boxes dynamically, but still require the user to save/update the post, you don't need to use AJAX at all. Just name the text fields appropriately so an array of values is POSTed, then handle it in your save action. It may be helpful to save this array in a single post meta key, so you can just loop through it to output the ...


9

The best way to do this is by adding 'user_can_richedit' filter, like so: add_filter( 'user_can_richedit', 'patrick_user_can_richedit'); function patrick_user_can_richedit($c) { global $post_type; if ('page' == $post_type) return false; return $c; } Hope it's useful ;)


9

Not sure if this still works. Preferably, drop this inside your theme's functions.php: add_filter( 'user_can_richedit' , '__return_false', 50 );


8

If it's getting too hard and complicated, you can simply add new buttons by using jQuery. Simply clone an existing or create a new button, and append it to the editor's toolbar. You can wrap the javascript with a php function, and run it in the admin footer or something. Or you can use the edButton function. Here is a dirty and fast written example for ...


8

You don't want to edit core WordPress code. You don't need to edit core WordPress code to do what you need to implement. First, you need to study the WordPress templating (i.e. Theme) functionality. Then, you need to study Plugins and the WordPress Hooks API, including its Action Hooks and its Filter Hooks. To do what you're describing, you definitely ...


8

Giving a blank array to 'supports' in the declaration of the post type should get rid of the editor and the title, along with every other default box in the edit post page. $supports = array (''); $args = array( 'label' => 'people', 'supports' => $supports, 'hierarchical' => false, 'public' => true, 'rewrite' ...


8

Hi @José Pablo Orozco Marín: If you are looking for how to code the custom buttons yourself, WordPress' Codex has a great example that shows you how: http://codex.wordpress.org/TinyMCE_Custom_Buttons The example is complicated because it shows you how to add your own controls but if you are using the standard buttons you don't need to make is to ...


8

I created two plugins that together should solve my needs. They are currently in an early alpha stage, and all comments are welcome. The base plugin is an On-Demand Resizer. This plugins monitors requests for non-existing files in the uploads dir, and creates images of the requested size if needed. For example, image-200x100.jpg will create and return ...


8

You have a couple of options. First, you can always click on the bottom right corner of the post edit box and drag to resize: However, you can also make it so that the post box is larger by default. Go to Settings > Writing, and change the value for size of the post box:


7

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 to true in your wp-config.php. You need this to ...


7

There's an easy way. Open functions.php and add this code. It works for many html entities // got this form http://www.sycha.com/wordpress-add-hr-button-tinymce-visual-editor function enable_more_buttons($buttons) { $buttons[] = 'hr'; /* Repeat with any other buttons you want to add, e.g. $buttons[] = 'fontselect'; $buttons[] = 'sup'; */ ...


7

There are a few functions that come in handy here: unstick_post - Unstick a post stick_post - Stick a post is_sticky - Figure out if a post is sticky With those three in mind, all we need to do is stick them together with some admin menu bar glue. First off, let's wrap everything in a class for fun and profit. This class will have some constants that ...


7

There is not a way to do this without modifying the core. You should see .php files that are in subdirectories, but you won't see anything above the root theme directory for .css files, and you won't see any JavaScript files. If you take a look at wp-admin/theme-editor.php, the relevant lines are... <?php $allowed_files = $theme->get_files( 'php', ...


7

I use Advanced Custom Fields for lots of front end post editing with meta boxes. ACF allows you to build lots of advanced meta box fields and adds them automatically to the back end post panel. But there is a front end function as well. This method is completely free. The only way it costs anything is if you want to use any of their more complex field type ...


6

The answer suggested by GavinR is correct. You don't need to install the suggested plug-in, though. Just add this mini plugin and you're set: <?php defined( 'ABSPATH' ) OR exit; /* Plugin Name: TinyMCE break instead of paragraph */ function mytheme_tinymce_settings( $tinymce_init_settings ) { $tinymce_init_settings['forced_root_block'] = false; ...


6

One change is that: theme_advanced_buttons1 is going to be changed to: toolbar1 which allows you to update the buttons so my new function will look something like: function myformatTinyMCE( $in ) { $in['toolbar1'] = 'bold'; $in['toolbar2'] = 'formatselect'; return $in; } add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' ); Also it looks ...


6

The strings was new, not more for your requirements. This is the new content of the hook. array ( 'selector' => '#content', 'resize' => 'vertical', 'menubar' => false, 'wpautop' => true, 'indent' => false, 'toolbar1' => ...


6

On a free and publicly available theme, yes, you can! If you built the theme yourself, yes, you can! If the theme is under a GPL license or completely public domain, yes, you can! But If you're a client of a developer who has built the theme for you however it may not be so simple. It may be in your contract that it be put there, and you should have ...


6

Just replace the default output. Make sure you unescape the excerpt before you send it to the editor: add_action( 'add_meta_boxes', array ( 'T5_Richtext_Excerpt', 'switch_boxes' ) ); /** * Replaces the default excerpt editor with TinyMCE. */ class T5_Richtext_Excerpt { /** * Replaces the meta boxes. * * @return void */ public ...


6

There is a hook for that: 'mce_css'. It is called in _WP_Editors::editor_settings() and you get all loaded stylesheets comma separated as the first and only parameter. Now it is easy: Use the global variable $editor_styles (here are your theme’s and parent theme’s editor stylesheets stored already), add the time of the file’s last modification as a ...


6

Thanks for the hint Bainternet, indeed this is very easy to implement with jQuery. Example (the four meta boxes are closed for clarity) : Here's what I did : var $j = jQuery.noConflict(); $j(document).ready(function() { $j("#side-sortables").append('<div id="container_div" class="postbox meta-box-sortables ui-sortable"><div ...


6

It's actually not too bad to do what you're asking. This should take you about an hour to do your first one, and 10 minutes to do subsequent ones. Ultimately what you're going to do is create a TinyMCE plugin. Here's what you should arm yourself with to start: Creating a tinymce plugin general guide Some rock solid example code A general guide on adding a ...


6

This should be what you're looking for - put this code into your theme's functions.php file: add_filter( 'tiny_mce_before_init', 'yourprefix_tiny_mce_before_init' ); function yourprefix_tiny_mce_before_init( $init_array ) { // filter styles: $init_array['theme_advanced_styles'] = "your_style=your_class"; // filter formats: ...


6

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 either case, you don't want to work on a live site ... things can ...



Only top voted, non community-wiki answers of a minimum length are eligible