Support » Themes and Templates » Escape ampersands in Custom Post Type loop titles

  • dkristine


    I created a custom post type for a restaurant called “menu” and am displaying the menu in a table like so:

    <?php $loop = new WP_Query( array( 'post_type' => 'menus', 'orderby'=> menu_order, 'category_name'=> 'dinner', 'posts_per_page' => -1) ); ?>
          <table id="yoshi-menu">
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
         <tr class="<?=($c++%2==1) ? 'odd' : 'even' ?>">
         <td class="image">
         <?php the_title(); ?></td>
         <td class="desc">
         <?php $values=get_post_custom_values('description'); echo $values[0];?>
         <td class="price-1">
         <?php $values=get_post_custom_values('price'); echo $values[0]; ?>
         <td class="image">
         <a rel="lightbox" href="<?php $big = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array( 1000,1000 ), false, '' );?><?php echo $big[0]; ?>"><?php the_post_thumbnail(array (60,60)); ?></a>
    <?php endwhile; ?>

    The individual posts validate fine, but if the client puts an ampersand “Steak & Prawns” in the title, this template returns validation errors. I have tried using html special characters, but then the titles simply return & amp ; literally (without spaces). Not sure why this is only happening in this particular template while ‘single-menu.php’ validates fine with an ampersand.

    Any help would be appreciated! I am a php newbie 🙂


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Escape ampersands in Custom Post Type loop titles’ is closed to new replies.