WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] When apply the PRE html tag to some line of code, STYLE tag vanishes from post (3 posts)

  1. riversatile
    Member
    Posted 2 years ago #

    Hi,

    When I apply the PRE html tag to some line of code, STYLE tag vanishes from post.

    I want to add code (contains php and html) to my posts.
    I heard I have to use the PRE html tag to do this, on some code it works, but the STYLE html tag vanishes and breaks my code.

    Here is the code I want to put in the PRE tag :

    <?php if (is_single()) {
        $css = get_post_meta($post->ID, 'css', true);
        if (!empty($css)) { ?>
            <style type="text/css">
            <?php echo $css; ?>
            </style>
        <?php }
    } ?>

    I want the same effect/appearance than above.
    How can I allow my WordPress to accept STYLE html tag in the PRE tag ?

    Thanks

  2. Have a look at these methods:

    Writing Code in Your Posts
    http://codex.wordpress.org/Writing_Code_in_Your_Posts

  3. riversatile
    Member
    Posted 2 years ago #

    Yes, I already found this post. OK... the issue is not in STYLE html tag. WordPress recognises html entities and transforms them with the graphic aquivalent !

    In the one hand, I can replace all the HTML entities like below (in each posts !) :

    <
    >
    /
    ]
    [
    "
    '

    or simply use a wordpress plug-in "Preserve Code Formatting"

    I choose the second way ^_^

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags