• Resolved assorted

    (@assorted)


    I need help with some php coding.

    Current code:

    if (is_category() || is_single() || is_archive()) {
    	echo '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
    	the_category('title_li=');
    	echo "</div> ";

    Current output:

    <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    	<a href="http://www.nhpborneo.com/catalogue/insects" title="View all posts in Insects" rel="category tag">Insects</a>
    </div>

    I need help so that it outputs this instead:

    <div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    	  <a href="http://www.nhpborneo.com/catalogue/insects" itemprop="url" title="View all posts in Insects" rel="category tag">
    	  <span itemprop="title">Insects</span></a>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot control the inner content of the output when using the_category(). If you use get_the_category(), you code is returned an array of the post’s category objects. Based on it’s content, you can construct and echo out any sort of HTML you desire.

    Thread Starter assorted

    (@assorted)

    Thank you bcworkz. I’ve managed to sort it out using get_the_category(),

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP for Breadcrumb’ is closed to new replies.