Search code examples
phphtmlwordpresspermalinks

Use permalink in PHP with HTML


I have a question using HTML and PHP combined.

I have this little code:

$args = array( 'post_type' => 'program', 'posts_per_page' => 100 );
$loop = new WP_Query( $args );

        while ( $loop->have_posts() ) : $loop->the_post();
        echo '<div class="singleprogram">';
            echo '<div class="entry-title"><a href="'the_permalink()'">';
            the_title();
            echo '</a></div>'; 
            echo '<div class="entry-content">';
            the_content();
            echo '</div></div>';

        endwhile;

If I use this, my page gets all blank. Any ID what I'm doing wrong??

( if i delete the_permalink() and leave a href="" blank then its working but of course it doesn't link to something )

Thanks in advance!


Solution

  • Thanks for the information. I found my own solution, don't know why this does work but it works.

    echo '<div class="entry-title"><a href="';
            echo the_permalink();
            echo '">';
            echo $post->post_title;
            echo '</a></div>'; 
    

    I had to break up the a href.

    Thanks