
你需要修改headerphp相关代码,
打开headerphp
在</head>后面寻找相关代码,不清楚headerphp代码,我也不清楚修改哪儿
你最好把headerphp代码用弄给我看,帮你修改代码即可
如果不想要这样的标题结构,可以于functionsphp取消掉title-tag
在functionsphp中找到
add_theme_support( 'title-tag' );将该句注释掉就可以了。
先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:
if(is_user_logged_in()){
$current_user = wp_get_current_user();
/
@example Safe usage: $current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
/
echo 'Username: ' $current_user->user_login '<br />';
echo 'User email: ' $current_user->user_email '<br />';
echo 'User first name: ' $current_user->user_firstname '<br />';
echo 'User last name: ' $current_user->user_lastname '<br />';
echo 'User display name: ' $current_user->display_name '<br />';
echo 'User ID: ' $current_user->ID '<br />';
}
(一)利用WORDPRESS关键词设置插件。这种方法是最方便,也是最容易的。首先,先在WORDPRESS安装插件里的搜索PlatinumSEO Pack 或All in One SEOPack其中一个插件,找到后点击安装就可以了。安装完成后就是启动插件了,启动后到WORDPRESS设置项下打开这个插件,在插件对应的项里输入你要添加的标题或描述。。。。它们能设置每个文章页面的title、description、keywords等项。(二)利用JS代码。这个方法稍微有点复杂,建议懂得JS编程的人使用。的“编辑”选项,进入主题编辑选项;这一步太简单,就不截图了。在模版里面点击“顶部(headerphp)”模版:在左侧的header编辑框中找到<title……………</title,这里是你的网站标题,中间的应该是变量,毕竟每个页面的标题都不一样。在<title前面或者</title后面加入以下代码:以下为引用的内容:<php if (is_home()){$description = “--此处填上你自己网站的描述--”;$keywords = “——你网站的关键词——”;}//判断是否是首页,如果是,指定关键词(keywords)和描述(description)。注意,把上面的关键词(keywords)和描述(decision)改成你自己的。elseif(is_single()){if ($post-post_excerpt) {$description = $post-post_excerpt;}elseif(function_exists(‘wp_thumbnails_excerpt’)){$description =wp_thumbnails_excerpt($post-post_content,true);}else {$description = $post-post_title;}$keywords = “”;$tags = wp_get_post_tags($post-ID);foreach ($tags as $tag ) {$keywords = $keywords “," $tag-name;}}//判断是否是文章页,如果是则文章标签(tag)设为关键词,摘要(可以在后台设置,这里就不讲解了)设为描述(description),若没有摘要,标题(title)作为描述(description)。elseif(is_category()){$description = category_description();}//判断是否为分类页echo “<meta name=\”description\”content=\”$description\” /<meta name=\”keywords\” content=\”$keywords\”/”;//这一步就是调用上面的函数了。设置好后点击更新保存就可以用了。
在Functionphp里面加入一段获取首张的函数:
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img+src=[\'"]([^\'"]+)[\'"]>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){
$first_img = get_bloginfo('template_directory')"/images/defaultjpg";
}
return $first_img;
}
调用代码(写出大致功能实现方法,具体样式请自己修改):
<php
query_posts(cat=分类ID,showposts=调用数量);
>
<ul>
<php if (have_posts()) :while (have_posts()) : the_post(); >
<li>
<img src="<php echo catch_that_image(); >" alt="<php the_title(); >" />//缩略图
<a href="<php the_permalink() >" ><php the_title(); ></a>//标题
/文章摘要开始/
<php
if ($post->post_excerpt) {
echo $post->post_excerpt;
}
else{
echo cut_str(strip_tags(apply_filters('the_content', $post->post_content)),40,"…");
}
>
/文章摘要结束/
</li>
<php endwhile; endif; >
</ul>
<php wp_reset_query(); >
以上就是关于wordpress 博客首页创建时标题如何修改 有图求解!WP标题修改全部的内容,包括:wordpress 博客首页创建时标题如何修改 有图求解!WP标题修改、高分求助:wordpress如何设置每个页面的Title、Wordpress中怎么单独调用某一级分类下的二级分类 标题 链接等等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)