I convert an HTML template to a WordPress theme. I use a custom field plugin to do this, but when I try to lode a map in the <iframe> tag the the output looks like <p><iframe {code..}></iframe></p>. How to remove this p tag that is automatically generated?
I used the following code in functions.php but it did not fix the problem:
<?php
remove_filter('term_description','wpautop');
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
?>
1.Login to WordPress Dashboard
2.Go to Appearance > Editor
3.Select Theme Functions (functions.php) file.
4.Add the following function and click update changes.
// Remove P Tags Around Images
function filter_ptags_on_images($content)`{return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);}
add_filter('the_content', 'filter_ptags_on_images');`
That’s all.
You can use Toggle wpautop plugin for that.
This may be very helpful for you.
Thanks
how to remove the automatic insertion of <p> </p> in text entry fields only, not in visual editor...
I put this in my function.php
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
It remove the auto <p> tag both text and visual editor is this possible to remove the <p> tag in text editor only... not in visual.
Paragraph tags are added when the Posts content is displayed and not when its stored in the database. You will not notice the paragraph tags when switching from Visual to Text mode or even when you view the posts content stored in the database using PHPMyAdmin or some similar means.
Check the following link to see the list of filters are applied when database writes happen for Post, Pages & Attachments
http://codex.wordpress.org/Plugin_API/Filter_Reference#Database_Writes
I don't want my WP editor to remove br and p tags when I'm saving and I don't want to install TinyMCE to achieve it. Just want to use br and p tags in WP default editor.
Is there a good way?
Bit of a necro, but for the <p> tag you can add a class or perhaps another property.
e.g.
<p class="nothing-relevant">Foo</p>
will not be stripped (using Gutenberg).
there are plugins that are more accurate, but you can just add these lines in functions.php
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
See more info here
i am trying to remove <P> tag those wordpress are generating automatically.
I have google for that and get solution like remove filter
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
But by using this its removing all <p> tag those i have already used in page content.
For example :
When i am putting plain text in page content like
This is example.
Wordpress wrapping these plain text in <p> tag like <P>This is example.</p>
How can i stop this adding <p> tag rather than removing all <p> tag.
Try this one it will remove extra <p> for a particulate page
http://wordpress.org/plugins/ps-disable-auto-formatting/
after configuring this plugin you get an option like this, showing on example site
http://www.wordpress-plugin.net/remove-automatic-p-paragraph-in-wordpress/
Use strip_tags() function, this will help you
One of the good plugin in wordpress is :
Row Html
Features of this plugin is :
Disable wptexturize (the function that creates smart quotes and other
typographic characters).
Disable automatic paragraph creation.
Disable image smilies.
Disable convert_chars (the function that converts ampersands to HTML
entities and "fixes" some Unicode characters).
I know there are a lot of topics on this, and I've already looked at all them and none of the solutions there apply to me.
I've put a shortcode to run a jscript for a responsive slider in the 'text' side of my page editor. Yet when I load the page, the source code has tons of paragraph tags after every line of the javascript. It even has a paragraph tag before it even asks for the content itself.
I've tried editing the functions.php file of my theme (Reason 2.0), but I'm not sure I could mark it up correctly, it's very php-heavy. I've also tried five of the plugins suggested here. None of them have any effect.
The code is horrendous, and looks like this:
<p> <!-- START REVOLUTION SLIDER --></p>
<div id="rev_slider_1_1_wrapper" class="rev_slider_wrapper" style="margin:0px auto;background-color:#E9E9E9;padding:0px;margin-top:0px;margin-bottom:0px;">
<div id="rev_slider_1_1" class="rev_slider" style="display:none;">
<ul>
<li data-transition="slidehorizontal" data-slotamount="5" data-masterspeed="300" data-link="http://www.secondhandculture.org/mad-men-and-attraction" >
<img src="http://www.secondhandculture.org/wp-admin/admin-ajax.php?action=revslider_show_image&img=uploads%2F2012%2F12%2Fmad-men-image.jpg&h=300&t=exact" ></p>
<div class="caption sft"<br />
data-x=”400″<br />
data-y=”20″<br />
data-speed=”300″<br />
data-start=”200″<br />
data-easing=”easeOutExpo”><img src="http://www.secondhandculture.org/wp-content/uploads/2012/12/Mad-men-text.png" alt="Mad Men"></div>
<div class="caption big_white sfr"<br />
data-x=”550″<br />
data-y=”140″<br />
data-speed=”300″<br />
data-start=”500″<br />
data-easing=”easeOutExpo”>How it makes us love <br><br />
what we know we should hate, <br><br />
and asks us why</div>
</li>
</ul>
<div class="tp-bannertimer tp-bottom"></div>
</p>
</div>
</div>
<p> <script type="text/javascript"></p>
<p> var tpj=jQuery;</p>
<p> tpj.noConflict();</p>
<p> tpj(document).ready(function() {</p>
<p> if (tpj.fn.cssOriginal != undefined)
tpj.fn.css = tpj.fn.cssOriginal;</p>
<p> var revapi1 = tpj('#rev_slider_1_1').show().revolution(
{
delay:9000,
startwidth:,
startheight:300,
hideThumbs:200,</p>
<p> thumbWidth:100,
thumbHeight:50,
thumbAmount:1,</p>
<p> navigationType:"none",
navigationArrows:"nexttobullets",
navigationStyle:"round",</p>
<p> touchenabled:"on",
onHoverStop:"on",</p>
<p> navOffsetHorizontal:0,
navOffsetVertical:20,</p>
<p> shadow:2,
fullWidth:"off",</p>
<p> stopLoop:"off",
stopAfterLoops:-1,
stopAtSlide:-1,</p>
<p> shuffle:"off"
});</p>
<p> }); //ready</p>
<p> </script></p>
<p> <!-- END REVOLUTION SLIDER --></p>
I had the same problem once, and add_filter( 'the_content', 'wpautop') does not work on my theme. So what I did was the following:
In the revo slider admin area, select the slider that is not displaying well.
Look for the troubleshooting tab (Bottom right) then change the values
Jquery No Conflict Mode = ON
Put JS Includes To Body = FALSE
(Important part) Output Filters Protection = By Compressing Output
That way, the script will be just in one line therefore the auto paragraph filter will just add the p tag to a single line
A common reason for this is that the theme author changed the priority of the output filters in the theme or even replaced the default ones with his/her own. So, when you insert the Revolution Slider shortcode, paragraph tags are inserter surrounding each line of output, breaking the Javascript code. The usual message in the Firefox error console is:
Error: SyntaxError: syntax error
Source Code:
</p>
This is a theme problem the theme author should fix. If you want to try to fix it yourself, look for a line like:
add_filter( 'the_content', 'wpautop' , 99);
and change the priority (the 99) of the filter to something like 9. That may help but also break something else. In some themes the code is not exactly that but you can look for a function adding or removing filters from the shortcodes output. You can see examples in the pages I linked below.
However, before doing that try this: recent versions of Revolution Slider have an option to avoid being filtered. When you create a slider, in the Troubleshooting box, there is an option named "Output Filters Protection". Enable it (I have used the "By Echo Output" option).
This is a known problem with some Wordpress themes. Also note, if the theme affected this plugin, it will surely affect other plugins.
A few comments about this problem are posted in http://pippinsplugins.com/never-remove-the-default-the_content-filters-in-themes/ and http://theandystratton.com/2011/shortcode-autoformatting-html-with-paragraphs-and-line-breaks
From the first link (Never Remove the Default the_content Filters in Themes):
There is a terrible, terrible practice among theme developers to remove some of the default filters that are applied to post and page content...
From the second link (Shortcode Autoformatting HTML with Paragraphs and Line Breaks):
... this mysterious issue of my shortcode output being mysteriously auto-formatted with paragraph tags and line-breaks... It’s globally removing two very important core content filters that WP has built-in... This makes this theme work perfectly and negatively affects ANY and ALL plugins that have shortcodes...
The final solution is the one commented in the second article:
Don’t use a theme that poor code in it.
Don´t use inline JS - use register_script() and wp_enqueue_script
function o99_load_my_scripts()
{
// Register for a plugin:
wp_register_script( 'custom-script', plugins_url( '/js/my-custom-script.js', __FILE__ ) );
// or
// Register for a theme:
wp_register_script( 'custom-script', get_template_directory_uri() . '/js/my-custom-script.js' );
// then, you can then enqueue the script:
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'o99_load_my_scripts' );