Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable WordPress from adding <p> tags

Tags:

wordpress

All I've got is the following little snippet of code:

<select size="1" name="EventHour<?php echo $i; ?>"> 
    <option>1</option> 
    <option>2</option> 
    <option>3</option> 
    <option>4</option> 
    <option>5</option> 
    <option>6</option> 
    <option>7</option> 
    <option>8</option> 
    <option>9</option> 
    <option>10</option> 
    <option>11</option> 
    <option>12</option> 
  </select> 
  : <!-- note this character -->
  <select size="1" name="EventMinute<?php echo $i; ?>"> 
    <option>00</option> 
    <option>05</option> 
    <option>10</option> 
    <option>15</option> 
    <option>20</option> 
    <option>25</option> 
    <option>30</option> 
    <option>35</option> 
    <option>40</option> 
    <option>45</option> 
    <option>50</option> 
    <option>55</option> 
  </select> 

The should output fine. However, WordPress adds a p-tag around both of my select-elements as well as around the ":"-character. This makes them all end up on different rows.

I've installed and activated the WordPress plugin "Disable Visual Editor WYSIWYG" on this page without any success. Any other ideas what I can do to stop this from happening? Thanks in advance!

like image 734
user1048676 Avatar asked Jun 28 '12 16:06

user1048676


People also ask

What does p do in WordPress?

paragraph. It is given margining and other styling via the Stylesheet. WordPress does a pretty good job of removing unnecessary clutter from the text editor in order to make the writing experience as natural as possible. One of the things it removes is the <p> tag.

How do I stop WordPress from removing line breaks?

The TinyMCE-Advanced plugin adds the option to disable the automatic removal of <p> and <br/> tags. The option to disable/enable WordPress line break is present in the Settings->TinyMCE Advanced panel.


4 Answers

Use this:

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

in your functions.php

Here's the complete answer: http://codex.wordpress.org/Function_Reference/wpautop#Disabling_the_filter

like image 179
Mirko Avatar answered Oct 19 '22 11:10

Mirko


Wordpress modifies and cleans your entered HTML both in the editor and at output.

Use this plugin to get unmodified markup into your posts:

https://wordpress.org/extend/plugins/raw-html/

like image 38
pixelistik Avatar answered Oct 19 '22 11:10

pixelistik


Try this in your functions.php

<?php remove_filter ('the_content', 'wpautop'); ?>
like image 3
Lucas Zardo Avatar answered Oct 19 '22 09:10

Lucas Zardo


You can minify your code. Wordpress won't destroy code if everything is on one line.

I do that when I want to put <style> or <script> tags inside certain posts.

like image 2
maker3 Avatar answered Oct 19 '22 10:10

maker3