Support » Fixing WordPress » Lose formatting calling author description.

  • This is in regards to using <?php the_author_description() ?> in the author.php file I created. I’ve successfully pulled the description data through, but it doesn’t appreciate any sort of relative formatting – including html/bbcode/tickmarks, nothing seems to work.

    Has anyone else encountered this and/or how would you suggest going about formatting certain areas of the description?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter jalongoria

    (@jalongoria)

    Dadgummit moshu, you’re just too good. I searched for a good 30 minutes with a combination of about 10 different keywords instances to find just ONE topic that actually address this issue with no success.

    I’m going to implement his solution and see how it turns out. Appreciate the assistance once again.

    Thread Starter jalongoria

    (@jalongoria)

    Moshu, unfortunately, the code at the bottom of the post was non-effective, but the patch code which modifies admin-functions.php:

    OLD
    LINE373= $user->description = wp_specialchars(trim($_POST['description']));

    NEW
    LINE373= $user->description = trim($_POST['description']); //don't convert < to < etc

    This works great for visual styling (bold, italic, etc.), but doesn’t allow for paragraphs/breaks in the text. Do you, or anyone else reading this, have any thoughts as to why it trims the <p> and <br /> tags?

    Thread Starter jalongoria

    (@jalongoria)

    Anyone else care to give it a guess? I’ve also recently tried $user->description = trim(nl2br($_POST['description'])) in an attempt to convert newline characters. No success. I am using Gespaa v2 theme and have added a author.php.

    It may not be the best solution and it may not work for everyone – but it works in my blog. I did the following in my author template:


    $curauth = $wp_query->get_queried_object();
    echo html_entity_decode($curauth->description, ENT_COMPAT, get_settings('charset'));

    Anyone know how to allow links in the author description?

    Thread Starter jalongoria

    (@jalongoria)

    McShelby, thank you for the input.

    Unfortunately, when I tried to implement the code you just spoke of, the issue was still left unresolved.

    I took a look at the $curauth information available in the template tag documentation once before and referred back to it once again when you posted your comment. This seems to be a bit of a reoccurring trend with the documentation, although it provide specific examples on attributes and segments of code, it doesn’t specifically provide examples on generating this inside The Loop or outside The Loop in totality, just snippets.

    How did you implement this in your page, do you happen to have the page code listed anywhere and/or could I have you post/email it to see how you’ve written this out, so I could take a look and see what you’ve done that I may not have to make this work?

    I can send you the code but basically it’s not much more than the above. You can see the code in action here: http://bluesome.net/post/author/soeren/

    That’s also the place were you can contact me directly by email. The whole “Bio” stuff is coming out of the user description field in the database – including the h3 an p tags.

    It works for me if I create a new author.php and paste the following code inside (I’ve tested it – doesn’t look great but is doing the job):

    <?php
    get_header();
    $curauth = $wp_query->get_queried_object();
    echo html_entity_decode($curauth->description, ENT_COMPAT, get_settings('charset'));
    get_footer();
    ?>

    It maybe that due to the layout of your theme you’ll not see any text on the page because of eg. layering issues, scrolling off the page borders, etc. To confirm that the code doesn’t work, take a look into the HTML source code in your browser.

    Remember that $curauth isn’t any built-in WP variable. It’s just local and could also be named $blah.

    What happens if you are using the above code? Any error messages? Also checked the HTML source code for error messages?

    Btw: I am using WP 2.0.4 but it also worked in at least 2.0.2.

    McShelby,

    So I can just put this into my template:

    <?php
    get_header();
    $curauth = $wp_query->get_queried_object();
    echo html_entity_decode($curauth->description, ENT_COMPAT, get_settings('charset'));
    get_footer();
    ?>

    and it will show the author description with links, formatting etc?

    That’s what it reads, isn’t it?

    Thread Starter jalongoria

    (@jalongoria)

    McShelby, thank you for the response and consideration of this issue.

    Using your snippet of code to the ‘T’, here is the results I’ve received in the author.php:

    Warning: cannot yet handle MBCS in html_entity_decode()! in /home/blog/blogurl.com/public_html/wordpress/wp-content/themes/gespaa_v2/author.php on line 4

    Any thoughts you might offer on this would be helpful.

    Thread Starter jalongoria

    (@jalongoria)

    SIDENOTE: The error above is repeated multiple times down the page. However, it doesn’t break apart the interface and is held within the cell that the content is presented in – ala regular HTML formatting. The version of WP I am using is 2.0.4 .

    Below is the original code I use to post content to said page that does work, but doesn’t allow breaks/paragraphing (although it somehow allows formatting of the text itself):
    <?php
    get_header();

    if ($posts) { $pcount_lp = sizeof($posts); foreach ($posts as $post) {start_wp();?>

    <div class="entry">
    <h3 id="post-<?php the_ID(); ?>" class="entrytitle">Who is <?php the_author(); ?>?</h3>
    <div class="entrybody">
    <?php the_author_description() ?>
    </div>
    </div>
    <?php } ?>
    <?php } else { // end foreach, end if any posts ?>
    <div class="entrybody"><p>Sorry, no information matched your criteria.</p></div>
    <?php } ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thread Starter jalongoria

    (@jalongoria)

    One last thing, although it does give the error, it still posts the formatted text(biography) at the very bottom.

    Thread Starter jalongoria

    (@jalongoria)

    It seems this might be a lost cause altogether and possibly not something that WP is initiating in the first place. I’ve come across several bugtracks on Google such as this one:

    http://bugs.php.net/bug.php?id=25670

    The similarity is striking, although the usage is different. I’m not sure what I’ll be able to accomplish in rectifying this issue at this point. I have no control over the PHP version installed. Think I’m hitting the wall on this?

    Sorry, I am also lost at this point. The only idea I have: Because it only seems to be a warning, you may turn it off by setting something like
    $old_error = error_reporting((E_ALL ^ E_NOTICE) ^ E_WARNING);
    .
    . (insert old code from above)
    .
    error_reporting($old_error);

    I haven’t tested the code, but hopes this cures the problem.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Lose formatting calling author description.’ is closed to new replies.