php开发博客等网站常用调用类代码总结!

原创 David  2021-10-29 22:53  阅读 368 次
>明月合作型SEO

<?php get_header();?>

<?php get_sidebar();?>

<?php get_footer();?>

 

 

Single.php  and  archive.php

1、循环介绍

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

 

<?php endwhile; ?>

<?php endif;?>

  • if(have_posts()) – 检查博客是否有日志
  • while(have_posts()) – 如果有日志,那么博客有日志的时候,执行下面 the_post() 这个函数。
  • the_post() – 调用具体的日志来显示。
  • endwhile; – 遵照规则 #1,这里用于关闭 while()
  • endif; – 关闭 if()

2、调用标题

<a href="<?php the_permalink() ?>"><?php the_title_attribute(); ?></a>

标题太长了怎么办?

<a href="<?php the_permalink() ?>"> <?php echo mb_strimwidth(get_the_title(), 0, 32, '...'); ?></a>

3、日志元数据

3-1、发布日期:<?php the_time('F d, Y') ?>—所属分类:<?php the_category(', ') ?> —文章标签

<?php the_tags('标签: ', ', ', ''); ?>—留言数:<?php comments_number('暂无评论', '1条评论', '% 评论' );?>

4、调用内容

4-1、全文调用

<?php the_content(); ?>

4-2、摘要调用

<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200,"……"); ?>

  • 更多按钮

<a href="<?php the_permalink() ?>">更多内容</a>

6、分页插件使用

Pagebar插件

wp-page-numbers插件

使用:在<?php endwhile; ?>和<?php endif;?>中间插入:

<?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>

  • 前一篇、后一篇调用

<div style="float:left"><?php previous_post_link('&laquo; %link'); ?></div>

<div style="float:right"><?php next_post_link('%link &raquo;'); ?></div>

 

8、添加评论模块

在<?php endwhile; ?>和<?php endif;?>中间插入<?php comments_template(); ?>

修改摘要调用为全文内容调用

删除更多内容调用标签

 

 

 

Product.php

3、图片方式调用

循环调用:

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

 

<?php endwhile; ?>

<?php endif; ?>

 

标题调用:<a href="<?php the_permalink() ?>"> <?php echo mb_strimwidth(get_the_title(), 0, 16, ''); ?></a>

 

图片调用:<?php include( TEMPLATEPATH . '/thumbnail.php' ); ?>

 

页面名字调用:<?php wp_title('');?>

 

4、分页插件使用

wp-page-numbers插件

使用:

<?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>

 

page page facture

copy single.php

search function facture

(1)copy search code

(2)facture search.php zhijie copy category directory

(3)adjust search function and

2.open header.php design module find search.code  一个form 表单

plaster 对比之

原:

<div id="search">

<form action="search.php" method="GET">

本站搜索:<input name="keywords" size="30" style=

"border: 1px solid rgb(204, 204, 204); color: rgb(102, 102, 102);"

value="淄博门窗" onClick="this.value=''" type="text">

<input src="images/button_search.gif" type="image"></form>

 

本站业务:<a href="http://www.sdmenchuang.com/" target="_blank">淄博门窗</a>,

<a href="http://www.sdmenchuang.com/" target="_blank">淄博阳光房</a>,

<a href="http://www.sdmenchuang.com/" target="_blank">淄博车库门</a>,

<a href="http://www.sdmenchuang.com/" target="_blank">淄博百叶窗</a>,

</div>

search code:

<form id="search" action="<?php bloginfo('url'); ?>/" target="_blank">

<input id="s" name="s"  class="searchInput"  style="border-style:none" type="text" value="<?php the_search_query(); ?>"/>

<input type="submit" class="searchBtn" onClick="if(document.forms['search'].searchinput.value=='- Search -')document.forms['search'].searchinput.value='';" alt="Search"  />

</form>

 

replace

style="border-style:none"

style="border: 1px solid rgb(204, 204, 204); color: rgb(102, 102, 102);"

 

type="submit"

src="<?php bloginfo('template_directory');?>images/button_search.gif" type="image">

 

在 </form>之前可以添加

<br/>本W业务 <a href="" target="_blank">于大伟</a>,

<a href="" target="_blank">于大伟</a>,

 

facture search.php,archive.php>>>>search.php   buyong revise  le

 

这两句为什么不直接替换好?因为替换好的可能不识别,没替换的部分才是通用的

——西门吹雪

 

category-id.php

 

Product.htm_>category-id.php

分类目录  分类二 快速编辑改名为产品展示  更新后 鼠标放于其上  看ID=3 则该名category-3.php 于是就为产品展示专门定制了一个网页。——西门吹雪

 

本文地址:https://www.rrdsyy.com/1816.html
关注我们:请关注一下我们的微信公众号:扫描二维码 号名称暂无
版权声明:本文为原创文章,版权归 明月SEO 所有,欢迎分享本文,转载请保留出处!
西安网站制作

发表评论


表情