Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

25

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


13

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


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


9

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; ?>


8

Or even simpler: echo wp_strip_all_tags( get_the_content() ); By using: get_the_content() Retrieve the post content. (Must be used in a Loop) An important difference from the_content() is that get_the_content() does not pass the content through the 'the_content'. This means that get_the_content() will not auto-embed videos or expand shortcodes,...


8

The code you have is correct and will handle the wording even if the case does not match. Your problem is probably that wherever Place Name is being output, it is not being passed through a WordPress translation function, __( 'Place Name' ) or _e( 'Place Name' ); Either that, or what you're trying to translate is being dynamically generated ... you gave ...


7

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


6

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


6

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


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


6

This seems to do it: function allow_nbsp_in_tinymce( $mceInit ) { $mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt'; $mceInit['entity_encoding'] = 'named'; return $mceInit; } add_filter( 'tiny_mce_before_init', 'allow_nbsp_in_tinymce' ); Also see: https://www.tinymce.com/docs/configure/content-filtering/#entities Any improvement ...


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" href="http://www.bigbrotheralbania6....


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, ceil(($...


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

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

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

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 = get_the_content();...


4

The method I prefer to use is just a bit shorter then the previous answer. <php $myExcerpt = wp_trim_words( get_the_content(), 20, '' ) ; echo $myExcerpt ; ?> The WordPress function wp_trim_words() returns only text (no images). wp_trim_words ( string $text, int $num_words = 55, string $more = null )


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

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


3

this string is displayed when you get a nonce mismatch, something that should not happen much under normal usage. If it does haen enough to make you aware to it then you should investigate the cause. Anyway, no easy filter for that string so you will have to use the translation api to replace it. add_filter ( 'gettext', 'wpse_120304', 10, 3 ); function ...


3

Install the plugin "Don't Muck My Markup". It adds a checkbox option to each page disabling auto insertion of <p> and <br> tags. There is also an option to do this site-wide.


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

If I remember right WordPress emulates magic quotes in any case and disregards server setting for them. But this is trivia. :) Practical part is to try stripslashes() on your value if you are getting it from form.


2

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


2

I just slightly modified @Bainternet's answer. Using a switch on post_type, it's even possible to redirect to different templates. The default will let wordpress ignore the my_print parameter and go on as usual. add_action("template_redirect", 'my_template_redirect_2322'); // Template selection function my_template_redirect_2322() { global $wp; ...


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.


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