• Resolved klo-wp

    (@klo-wp)


    Hi,

    Im trying to add this on echo but seems not work, I’m sure I’m doing this wrong…

    <?php
    if ( in_category( 'wordpress-theme' )) {
    	echo '<a href="https://example.com/<?php the_title(); ?>" class="test"></a>';
    } ?>

    im not getting the output of <?php the_title(); ?>

    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Try

    <?php
    if ( in_category( 'wordpress-theme' )) {
    	echo ('<a href="https://example.com/<?php the_title(); ?>" class="test"></a>');
    } ?>
    Thread Starter klo-wp

    (@klo-wp)

    broadleon

    Put code in between back ticks. Check Allowed markup, so i can view all your code.

    thanks

    Try this:

    <?php
    if ( in_category( 'wordpress-theme' )) {
    	echo '<a href="https://example.com/' . the_title() . ' class="test"></a>';
    } ?>

    Thread Starter klo-wp

    (@klo-wp)

    Josh,

    Doesn’t work. I get the title outside the link, i need it inside.

    <a href="https://example.com/<?php the_title(); ?></a>

    should be:
    https://example.com/TEST

    thanks

    Thread Starter klo-wp

    (@klo-wp)

    broadleon,

    doesn’t work this too.

    anyway, thanks.

    How about this?

    <?php
    if ( in_category( 'wordpress-theme' )) {
    	echo '<a href="https://example.com/';
    	echo the_title();
    	echo '" class="test"></a>';
    } ?>

    I missed a closing quotation mark in my reply above (first reply). This should work also:

    <?php
    if ( in_category( 'wordpress-theme' )) {
    	echo '<a href="https://example.com/'.the_title().'" class="test"></a>';
    } ?>
    Thread Starter klo-wp

    (@klo-wp)

    Thanks Josh, this worked ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Why won't this echo in PHP’ is closed to new replies.