WordPress.org

Forums

Echo printing error (10 posts)

  1. Shashikanta
    Member
    Posted 3 years ago #

    Line number 8 exho error, help me for the correct format

    <?php
    // The Query
    $the_query = new WP_Query( 'cat=13&post_type=publication&numberposts=5' );
    
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
    echo '<li>';
    echo '"<a href="the_permalink()"> the_title()"</a>"';
    echo '</li>';
    endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    ?>
  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Replace:
    echo '"<a href="the_permalink()"> the_title()"</a>"';

    with:
    echo '<a href="' . the_permalink() . '">' . the_title() . '</a>';

  3. Shashikanta
    Member
    Posted 3 years ago #

    Not working

    Showing below result like this

    http://project.xxx.com/wp-content/plugins/wp-publication-archive/includes/openfile.php?file=http|project.xxx.com/wp-content/uploads/2012/03/tor_process_monitoring.pdfThis is a demo file (Download Publication)

    http://project.xxx.com/wp-content/plugins/wp-publication-archive/includes/openfile.php?file=http|project.xxx.com/wp-content/uploads/2012/03/GuidelineTender_Data_Card-Jajpur1.docReport 2012 (Download Publication)

  4. Shashikanta
    Member
    Posted 3 years ago #

    But the links are ok

  5. esmi
    Forum Moderator
    Posted 3 years ago #

    And where is the error now?

  6. Shashikanta
    Member
    Posted 3 years ago #

    yes same thing i am wondering

    Check this http://project.xxx.com/progress

  7. esmi
    Forum Moderator
    Posted 3 years ago #

    where is the error now?

  8. Shashikanta
    Member
    Posted 3 years ago #

    linking is not done as per our coding

  9. esmi
    Forum Moderator
    Posted 3 years ago #

    All I did is fix the syntax errors in your code.

  10. Shashikanta
    Member
    Posted 3 years ago #

    I got it I'm already in a php block and opening another one. I should be doing something like this

    <?php $the_query = new WP_Query(...); ?>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    "><?php the_title(); ?>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags