从wordpress2.9开始就可以使用自带的缩略图功能了,实现方法也很简单
1.添加功能
在function.php中插入代码
add_theme_support('post-thumbnails');
插入之后会在后台编辑文章的页面的右下角出现特色图片,(有的版本可能是或者是文章缩略图)
点击设定特色图像后出来的就是和插入图片相同的界面,但是仔细看会发现在本地上传图片后,或者从媒体里打开文件下面会多了作为特色图像的选项
点击后等它显示完成便可以把小窗口关掉了~
2.如何调用
在要显示的 地方加入代码
<?php the_post_thumbnail(); ?>
既可以调用,例如插入入在首页的大循环中。
3.后续改进
(1)如果没有缩略图时调用其他图片
复制代码
代码如下:
<?php
if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail(); ?>
<?php } else {?>
<img src=”<?php bloginfo(‘template_url’); ?>/images/xx.jpg” />
<?php } ?>
把下面的那个改成你自己图片的地址就可以了~
(2)控制缩略图大小
在function.php中刚刚插入的add_theme_support( ‘post-thumbnails’ ); 后面添加
复制代码
代码如下:
set_post_thumbnail_size( 50, 50, true );
尺寸的设置顺序是: 宽度、高度(以像素为单位)
(3)一张图片,要有多种大小的缩略图
在function.php中刚刚插入的add_theme_support( ‘post-thumbnails’ ); 后面添加
复制代码
代码如下:
set_post_thumbnail_size( 155, 110, true ); // 305 pixels wide by 380 pixels tall, set last parameter to true for hard crop mode
add_image_size( ‘one’, 155, 110, true ); // Set thumbnail size
add_image_size( ‘two’, 350, 248, true ); // Set thumbnail size
add_image_size( ‘big’, 546, 387, true ); // Set thumbnail size
其中第一个为默认的缩略图大小,后面三个是特殊的大小,可以根据实际情况使用。引号中的one,big,two也可以换成自己想要的名称。
调用,以调用350px*248px的为例,
复制代码
代码如下:
<?php
$thumbID = get_the_post_thumbnail( $post->ID, ‘two’, $imgsrcparam ); ?>
<?php echo “$thumbID”; ?>配合之前的那个,最后的代码就是:
<?php
if ( has_post_thumbnail() ) { ?>
<?php
$thumbID = get_the_post_thumbnail( $post->ID, ‘two’, $imgsrcparam ); ?>
<?php echo “$thumbID”; ?><?php } else {?>
<img src=”<?php bloginfo(‘template_url’); ?>”/>
<?php } ?>
阅读全文
找到好久才找到这个好东西
貌似采用这个Walker,翻译成“处理流程”可能比较好
第一步,在菜单处理流程里添加分割线
class Main_Menu_Walker extends Walker_Nav_Menu{
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>\n";
if ($depth == 0)
$output .="<li class='separator'>|</li>\n";
}
}
然后就可以使用li:last-child把最后一个分割线隐藏,当然也可以用另外一个办法,就是加过滤器
function menu_remove_last_separator($items){
$separator = "<li class='separator'>|</li>";
$pos = strrpos($items, $separator);
if ($pos)
$items = substr_replace($items, '', $pos, strlen($separator));
return $items;
}
add_filter( 'wp_nav_menu_items','menu_remove_last_separator');
最后就是在wp_nav_menu中使用这个处理流程了,例子如下
wp_nav_menu(array(
'theme_location' => 'navigation',
'container' => false,
'menu_class' => 'inline',
'walker' => new main_menu_walker()
)
);
阅读全文
奶奶的,我找了老半天才找到这段代码,我放在functions.php里,运行正常
他还有个功能,每个widget都有自己的编号了,比如("widget-1", "widget-2", 等等).
这样就好写样式了
/**
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
*/
function widget_first_last_classes($params) {
global $my_widget_num; // Global a counter array
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
if(!$my_widget_num) {// If the counter array doesn't exist, create it
$my_widget_num = array();
}
if(!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) { // Check if the current sidebar has no widgets
return $params; // No widgets in this sidebar... bail early.
}
if(isset($my_widget_num[$this_id])) { // See if the counter array has an entry for this sidebar
$my_widget_num[$this_id] ++;
} else { // If not, create it starting with 1
$my_widget_num[$this_id] = 1;
}
$class = 'class="widget-' . $my_widget_num[$this_id] . ' '; // Add a widget number class for additional styling options
if($my_widget_num[$this_id] == 1) { // If this is the first widget
$class .= 'widget-first ';
} elseif($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) { // If this is the last widget
$class .= 'widget-last ';
}
$params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']); // Insert our new classes into "before widget"
return $params;
}
add_filter('dynamic_sidebar_params','widget_first_last_classes');
阅读全文
Su 用户名 切换用户(直接用”su”这个命令,输入密码就可以是管理员权限了)
然后更新源
1. cd /etc/yum.repos.d
2. mv CentOS-Base.repo CentOS-Base.repo.backup
3. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
4. mv CentOS6-Base-163.repo CentOS-Base.repo
5.yum clean all
然后安装SSH
1,安装SSH
yum install ssh
2,启动SSH
service sshd start
3,设置开机运行
chkconfig sshd on
Ifconfig 查看连接信息(我用虚拟机安装的,需要查看虚拟机分配到了什么IP)
然后就可以通过putty在其他系统下进行管理了
阅读全文
我喜欢在路由里屏蔽一些自己不喜欢的站
小米这个垃圾公司一直欺骗人民群众
所以我就屏蔽了
最近他推出了新的域名mi.com,我在落伍看到的
然后我也在路由里屏蔽了
然后上网的时候发现网速就很慢了~
比如打开淘宝,以前都是2~3秒打开,屏蔽后就一直在载入,30秒都开不了
然后我突发奇想把路由里的URL过滤关掉,发现竟然秒开了
然后我检查了一会,发现一屏蔽mi.com,网页就难打开
然后我想到了一个问题,会不会光猫里的这个URL过滤是正则的,字母越短或者域名越短
他就要努力地去匹配,导致处理芯片资源消耗过高,然后就出现网速慢,无法打开网页的尴尬境地
阅读全文
放了半小时音乐,用世界之窗浏览天猫,然后觉得卡卡的,还以为是chrome的通病不清缓存。
迫不得已关了世界之窗,开了火狐,结果还是那鸟样。
顿时疑惑起来,还有哪个垃圾软件那么占资源?
除了杀毒,就开了个QQ和酷我,然后我把酷我一关。
回到火狐,速度杠杠的了。
唉,一个放音乐的软件也能让电脑卡成那样,服了
然后下了个千千静听听歌,还是老软件好,新软件像个卵样,就知道广告广告广告
阅读全文
//这个方法针对/xxx.html有用 $(document).ready(function () { $(".nav>ul>li").each(function (index) { var strs = new Array(); strs = window.location.href.split("/"); var http = strs[(strs.length) – 1];//获取最后一个“/”的地址 var liValue = $(".nav ul li").eq(index).children().attr("href").substr(0, 3);//获取菜单项链接的前4个字符 if (http.indexOf(liValue) >= 0) {//用包含比较是否相同 $(".nav ul li").removeClass("n-hover"); $(".nav ul li").eq(index).addClass("n-hover"); } $(this).click(function () { $(".nav ul li").removeClass("n-hover"); $(".nav ul li").eq(index).addClass("n-hover"); }); }); });
// nav $(function shownav() { var a1 = window.location.href;//当前url地址 var a2 = $(".nav>ul>li");//菜单的项">"为选取第一层,不考虑嵌套 var strs = new Array(); strs = a1.split("/"); for (var i = 0; i < a2.length; i++) { if ($(a2[i]).children().attr("href") == strs[(strs.length) – 1]) {//菜单项的地址是否等于当前链接 也没考虑最后是/的情况 $(a2[i]).addClass("n-hover"); return; } } })
阅读全文
# 泛域名解析 <VirtualHost 你的ip:80> ServerName *.xxx.com ServerAlias *.xxx.com DocumentRoot "x:/Fanyuming" <Directory "x:/Fanyuming"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all
x:/Fanyuming 放一个文件index.php 负责解释泛域名指向 <?php $url_this=$_SERVER [‘HTTP_HOST’]; $url_this=str_replace ("www.", "", $url_this); $url_this=str_replace (".xxx.com", "", $url_this); $url_this=str_replace ("’", "", $url_this); $url_this=str_replace ("@", "", $url_this); $url_this=str_replace ("=", "", $url_this); $url_this=str_replace (";", "", $url_this); //固定二级域名优先解析 if($url_this==’2008′) { header("location:"."http://www.xxx.com/zhuanti/ds13/ "); } if($url_this==’2009′) { header("location:"."http://www.xxx.com/aboutus/yantaohui/"); } if($url_this==’pku’) { header("location:"."http://www.xxx.com/zhuanti/yantao/"); } $dbh = mysql_connect(‘localhost’,’用户名’,’密码’); mysql_select_db(‘数据库名’); $query = "从数据库查询记录"; $res = mysql_query($query, $dbh); $err = mysql_error(); if($err){ echo "发生错误,请通知站长"; exit; } $row = mysql_fetch_row($res); if(empty($row[0])) { echo ""; exit; } else { header("location:"."http://www.xxxx.com/member/index.php?uid=".$row[0]); } ?>
阅读全文
注意:一定要先备份数据!!
To select users who have no posts or comments, you can use this:
SELECT * FROM wp_users WHERE ID NOT IN (SELECT post_author FROM wp_posts UNION SELECT user_id FROM wp_comments) 然后, 把’SELECT *’ 替换成 ‘DELETE’ 就实际地删除用户。
还可能有一些多余的数据在wp_usermeta。
可以把他们找出来
SELECT * FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users) 然后, 把’SELECT *’ 替换成 ‘DELETE’ 就实际地删除这些记录。
阅读全文
江南之恋(隆力奇)广告MV http://video.sina.com.cn/v/b/88325010-2559751183.html
阆中之恋_沙宝亮姚贝娜 http://video.sina.com.cn/v/b/122504150-3095427285.html
还有一些
《康美之恋》康美药业赞助拍摄,由谭晶演唱,李冰冰、任泉出演。 《仙林青梅》,由杨竹青演唱 《爱到春潮滚滚来》,由付迪生和任静演唱,以上两个由五粮液赞助拍摄;还有一个<香醉人间五千年>,由韩磊演唱 《风雨同行》由奥康鞋业赞助拍摄
《国参传奇》由康美新开河(吉林)药业有限公司拍摄,韩磊演唱,唐国强出演。 《黄鹤楼》:黄鹤楼形象MV 《梦在竹溪》: 竹溪形象MV 《梦入桃花源》:桃花源形象MV 《香醉人间五千年》:五粮液形象MV 《凯撒之歌》 :凯撒形象,韩磊演唱,吴秀波、许晴出演。 《江南之恋》:由隆力奇赞助拍摄,由著名歌手谭晶演唱
《菊皇茶语》:2012年康美药业最新推出的音乐电影。郭富城、刘一格对唱,郭富城、李冰冰出演。
阅读全文