[ create a new paste ] login | about

Link: http://codepad.org/QOUWc3XB    [ raw code | output | fork ]

PHP, pasted on Aug 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
WRONG

<ul>
<?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><?php the_title(); ?> ( <?php setPostViews(get_the_ID()); echo getPostViews(get_the_ID()); ?> )</li>
<?php endwhile; endif; wp_reset_query(); ?>
</ul>

CORRECT

<ul>
<?php setPostViews(get_the_ID()); ?>
<?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><?php the_title(); ?> ( <?php echo getPostViews(get_the_ID()); ?> )</li>
<?php endwhile; endif; wp_reset_query(); ?>
</ul>


Output:
1
2
3
4
5
WRONG

<ul>

Fatal error: Call to undefined function query_posts() on line 4


Create a new paste based on this one


Comments: