Wordpress 修改 - 在文章段落中加入广告
2008-05-01 14:13对 Wordpress 稍作修改,就可以在文章的段落之间自动加入图片或文字广告。在 index.php 或 single.php 中找到 < ?php the_content(); ?> 替换为下面的代码即可: <?php $content = apply_filters(’the_content’, $post->post_content); $save = explode(”</p>”, $content); $count = 1; foreach ($save as $a){ if ($count == 3){ echo’ 在这里放上你的广告代码,比如... [阅读全文]
Wordpress 修改 - 限制标题长度
2008-04-30 06:11
在边栏或其他地方调用文章时,有时候为了界面美观需要限制一下文章标题的字数,可以用下面的代码实现: <?php $my_query = new WP_Query('showposts=5'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php if (strlen(the_title('','',FALSE)) > 30) { $title_short = substr(the_title('','',FALSE), 0, 30); preg_match('/^(.*... [阅读全文]
Wordpress 指定某个分类的文章到首页显示
2006-07-15 06:49If you are finished with the posts in the original query, and you want to use a different query, you can reuse the $wp_query object by calling query_posts() and then looping back through. The query_posts() will perform a new query, build a new posts array, and reset the loop counter. // Get the las... [阅读全文]
最新评论