Hot answers tagged

15

The "classic" TinyMCE editor has two dropdowns: formatselect for paragraph styles and styleselect for character styles - which can also contain paragraph styles, to make it more confusing. The configuration in WordPress by default only shows the format dropdown. If you apply a custom stylesheet to the editor, TinyMCE can use it to pick up the classnames and ...


13

The answer by shea is not ideal as in many cases: You don't want to strip everything from <br>, <p> etc. You want it as a default behavior for your WP visual composer which the above code will delete In many cases it is considered as "hacking the core" as this is changing the default core behavior of WP - for example such a thing will not pass ...


9

You can add a hebrew shortcode to wrap around your hebrew text and then use the CSS2 direction attribute to indicate the text direction. e.g.: In your themes functions.php: function hebrew_shortcode( $atts, $content = null ) { return '<p lang="he" DIR="RTL">' . $content . '</p>'; } add_shortcode( 'hebrew', 'hebrew_shortcode' ); Your ...


7

you can do it like this: //add my_print to query vars function add_print_query_vars($vars) { // add my_print to the valid list of variables $new_vars = array('my_print'); $vars = $new_vars + $vars; return $vars; } add_filter('query_vars', 'add_print_query_vars'); then add a template redirect based on that query_var: ...


6

Simple answer: add_shortcode( 'hidemytext', '__return_false' ); But shortcodes should never be used like that. Imagine what happens when the plugin or theme with that shortcode is turned off: everyone can see the content now. This is not very user friendly. So switch the logic: show nothing or the bare shortcode tag by default, show the content only if ...


5

OK, attempting to remove the with jQuery is counter intuitive. Modifying it via output buffering is inefficient. And we shouldn't edit the actual widget code itself, since this will revert back next time we update WordPress. I would suggest either creating your own text widget, or simply extend and modify the existing WordPress widget as follows (put the ...


5

Try this (you may need to bootstrap WP by loading wp-load.php, depending on where you put this code). $args = array( 'post_type' => 'post', 'post_status' => 'publish', //'posts_per_page' => -1 //uncomment this to get all posts ); $query = new WP_Query($args); while ( $query->have_posts() ) : $query->the_post(); $f = ...


5

I’ve done something similar taking the simple approach of adding a CSS class to titles based on their character count. That CSS class then decreases letter-spacing and/or font-size. // Count the characters, taking Unicode into account $chars = mb_strlen($post->post_title); // For every 10 characters after the first 20, add a size $size = max(0, ...


5

Take a look at your page source. The offending area is a section of content that's being output after the closing </html>. Judging from some of the links in that appended area, I'd say there a good chance you've been hacked, unless these look like yours: <div style="text-indent:-9999em"> <a rel="follow" ...


4

A little tip a lot of people don't know about. You can copy/paste an image url into the upload field and it will be auto uploaded into your blog. Right click the image you want to save and select copy image URL (chrome) In your blog click Add Image--> Select Files ( from computer)-->paste url into the upload dialog where it says "file name". This ...


4

Hi @Nam Gi VU: I'm pretty sure that's not possible directly. What you could do would be to export all posts to a text file, use a search and replace in a text editor and then import them back in deleting all the posts before you reimport them. Be careful to change a copy of the export in case your search and replace corrupts the file and makes it fail to ...


4

In your functions.php file where the custom post type is registered do you see: 'supports' => array('title','editor','thumbnail') or something similar? If so remove 'editor'


4

You have multiple options here, depending on the amount of flexibility you want to give the editor of the text blocks. Create a custom loop with WP_Query. See our examples and the Codex page for usage. Then you print the excerpts of the page these boxes are linked to. You can use attachments (images) and the full formatting here. Use widgets. See our ...


4

There's not a native WordPress function to retrieve text only, but you can use WordPress filters and regex code to target this specific problem. To get unformated text, use get_the_content() function. To apply all filters, use it this way( see codex: http://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage ): $content = ...


4

The wpautop() function adds <p> and <br> tags to your content in order to preserve line breaks. If you would rather add these tags yourself, then you can remove the filters which apply this function to the post content: remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); If you would like to keep the automatic ...


4

Try removing (image), like this: <?php $content = get_the_content(); $content = preg_replace("/<img[^>]+\>/i", " ", $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; ?>


3

A cursory search doesn't turn up any plugins that do this ... but you could use the built-in exporter as an example for building out your own plugin. It's located in /wp-admin/includes/export.php. Essentially, it's a PHP page that queries the database to get all of your posts, then dumps the content into a pre-build XML template that can be imported later. ...


3

The plugin repository contains a few options that you could use. At a glance this one looks promising.


3

This is because the images are defined as floating to the left. To solve this, you can add a clear: both to the <h4> elements (it probably won't hurt to do this in the stylesheet - will there be a situation where you need a title that exists next to a float?).


3

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 == ...


3

The value of the textarea must be printed between the opening and the closing tag: <form action="/"> <textarea name="whatever"><?php echo esc_textarea( $description ); ?></textarea> </form> Note the usage of the function esc_textarea() here. It prevents any possible character inside the variable $description from being ...


3

It seems that error is in your theme.min.css. The Font Awesome Icon which should appear in the browser is added via CSS using content. But the CSS does not contain the icon information but these weird looking characters. For Example: .fa-music:before{content:"&iuml;&iuml;&iquest;&frac12;&iuml;&iquest;&frac12;"} I cannot tell why ...


2

You have at least three different ways: 1) Edit directly in the database. The content of the post is stored in post_content column of wp_posts table. Since you are running your own WordPress, you should have full access to that. Just use SQL to do search and replace. Remember, the table content is sort-of HTML, so may have tags and/or escaped characters 2) ...


2

Hot-linking images is bad form, which means that you need to attach images to your post. So, copy/paste really won't work. You just need to save the image, and then upload it to you post.


2

WordPress emulates magic_quotes_gpc and won't be deprecating this for some time due to concerns over plugin security and backward compatibility. To work around this, you need to use stripslashes() or, if you need to strip slashes when data arrives via $_POST, $_GET, $_COOKIE, and $_REQUEST arrays, you can use the WordPress stripslashes_deep() function: ...


2

If You need title from media use something like this: <?php $thumb = get_post(get_post_thumbnail_id()); echo $thumb->post_title;


2

You can add it as an argument: <?php wp_dropdown_categories( 'show_option_none=CHOOSE THE CATEGORY!' ); ?> Reference: wp_dropdown_categories


2

Try this: <?php //Custom header // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' )) && $image[1] >= ...


2

You can try to make use of filters in query (likely posts_where) to make it look for match between clean value and MySQL REGEXP command (if it fits, didn't use it myself) with your logic, run on raw value.


2

The _n (see Codex) function accepts four arguments. The first two are texts to be translated (the first is singular, the second plural), the third argument is a number (in this case $count). When $count is 1 the first string is used, otherwise the second string is used. So in fact the first instance of $count is only used to determine whether the single / ...



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