我正在使用WordPress插件WP-PostViews来显示帖子的视图数量。我正在使用此代码,它很好用:
<?php if(function_exists('the_views')) { the_views(); }?>
Run Code Online (Sandbox Code Playgroud)
我想做的是将一定数量的帖子视图用作变量,但是我无法使其正常工作。到目前为止,我已经尝试过:
<?php if(function_exists('the_views')) { $variable = the_views(); } ?>
Run Code Online (Sandbox Code Playgroud)
和
<?php if(function_exists('the_views')) { $variable = the_views(); } else { $var = 0; } ?>
Run Code Online (Sandbox Code Playgroud)
到目前为止没有成功。有人有建议吗?