Support » Fixing WordPress » Code for post view

  • Basically, I want to display my post view counter on the single.php under the title.
    I have this code:

    pvc_post_views( $post_id = 0, $echo = true );

    and here is the place where it shouldgo:

    echo '<span class="entry-meta-comments"></span>' . "\n";

    however if I put it like this:

    echo '<span class="entry-meta-comments">pvc_post_views( $post_id = 0, $echo = true );</span>' . "\n";

    then the plugin does not show.
    Have I built the code line wrong? Please help

Viewing 5 replies - 1 through 5 (of 5 total)
  • echo '<span class="entry-meta-comments">' . pvc_post_views( $post_id = 0, $echo = true ); . '</span>' . "\n";

    echo '<span class="entry-meta-comments">'; pvc_post_views( $post_id = 0, $echo = true ); echo '</span>' . "\n";

    Thread Starter acqua

    (@acqua)

    Thank you Michael it looks better now.
    However I get the post count on another line.
    I would like it to be on the same line as all the other elements.
    Please see the complete code below

    echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i><a href="' . esc_url(get_month_link(get_the_time('Y'), get_the_time('m'))) . '">' . get_the_date() . '</a></span>' . "\n";
    			echo '<span class="entry-meta-author author vcard"><i class="fa fa-user"></i><a class="fn" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>' . "\n";
    			echo '<span class="entry-meta-categories"><i class="fa fa-folder-open-o"></i>' . get_the_category_list(', ', '') . '</span>' . "\n";
    			echo '<span class="entry-meta-comments"><i class="fa fa-comment-o"></i><a class="mh-comment-scroll" href="' . esc_url(get_permalink() . '#mh-comments') . '">' . absint(get_comments_number()) . '</a></span>' . "\n";
                            echo '<span class="entry-meta-comments">'; pvc_post_views( $post_id = 0, $echo = true ); echo '</span>' . "\n";

    the extra line might be caused by some formatting; impossible to say without a link to your site.

    Thread Starter acqua

    (@acqua)

    [ ping to user removed: Please don’t ping folks who are already on the thread. ]

    Please have a look
    http://backdoorpodcast.com/dnpcd-podcast-le-rubriche-e-il-basket-raccontato-col-sorriso/

    the code is the one under meta indicating the post views (xx LETTURE)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Code for post view’ is closed to new replies.