WordPress.org

Ready to get started?Download WordPress

Forums

wp_parse_args (2 posts)

  1. thienvien2008
    Member
    Posted 5 years ago #

    [links moderated]
    Small example to reproduce the bug:

    Open your sidebar.php and add this:
    <?php wp_list_categories('title_li=<h2>Pages&Categories</h2>'); ?>
    or
    <?php wp_list_categories('title_li=<h2>Pages & Categories</h2>'); ?>
    or
    <?php wp_list_categories('title_li=<h2>Pages & Categories</h2>'); ?>

    As result "Categories</h2>" part will disappear.

    origin of bug : "Categories</h2>" is considered by wp_parse_args as an unkown argument (because of the "&").

  2. Jeremy Clarke
    Member
    Posted 4 years ago #

    when you use url-query style arguments you can't have complex strings like that, all the values have to be simple strings without spaces (slugs).

    If you want to pass in complex strings you should use an array definition instead like this:

    wp_list_categories(array('title_li'=>"<h2>Pages & Categories</h2>"));

    Codex Article about wp_parse_args()

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.