日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

wordpress主题

發布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 wordpress主题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.創建wordpress主題:在themes文件下建立新主題black文件夾

2.在black文件夾中放入index.php和style.css文件,
其中index對style.css文件的引用
?<link rel="stylesheet"? href="<?php bloginfo('stylesheet_url');?>"? type="text/css" media="screen" >

?

<!-- 博客地址 -->
<?php bloginfo('url'); ?>
<!-- 博客名字 -->
<?php bloginfo('name'); ?>
<!-- css地址 -->
<?php bloginfo('stylesheet_url');?>

網站描述?<?php bloginfo('description');?>
網站關鍵字?<?php bloginfo('keywords');?>

網站標題在頭<?php wp_header();?>中已經包含,其實不用單獨提出

網站各類文件地址的引用,如js文件的引用,不過一般通過在functions.php中添加后,再通過<?php wp_footer();?>調用

  • home_url() 首頁URL http://www.example.com
  • site_url() 網站目錄URL http://www.example.com? 或 http://www.example.com/wordpress
  • admin_url() 管理目錄URL http://www.example.com/wp-admin
  • includes_url() 包含目錄URL http://www.example.com/wp-includes
  • content_url()? 文章目錄URL http://www.example.com/wp-content
  • plugins_url() 插件目錄URL http://www.example.com/wp-content/plugins
  • theme_url() 主題目錄URL http://www.example.com/wp-content/themes
  • wp_upload_dir() 上傳目錄URL (返回一個數組) http://www.example.com/wp-content/uploads

?<?php bloginfo('template_url');?> 獲取主體文件位置
<?php bloginfo('stylesheet_url');?>獲取樣式表位置
以上兩條也可以通過function.php添加到header和footer中

?

?

?

主題必需頁面

  • 404 error page,
  • archive page (our hero today),
  • image attachments page,
  • index page (the main page),
  • default?page template (for pages),
  • search results page,
  • single post and attachment pages.

?

sidebar
1)在functions.php中

// 顯示后臺菜單-小工具,并注冊sidebar
if ( function_exists('register_sidebar') ) {register_sidebar(array('name' => 'rightBar','before_widget' => '<aside class="widget clearfix">','after_widget' => '</aside>','before_title' => '<h2>','after_title' => '</h2>',));
}

2)建立sidebar.php文件

<div><?php if ( ! dynamic_sidebar( 'rightBar' ) ) : ?><?php endif; ?>
</div>

3)引用sidebar文件

//獲取sidebar文件內容
<?php get_sidebar(); ?>//獲取sidebar-news文件內容
<?php get_sidebar(‘news’); ?>

?

single.php

對于文章單頁,文章框架代碼仍然需要放在一個循環中,只不過到了單頁面,只循環一次,所以while可以去掉。

<?php if ( have_posts() ) : the_post(); ?><?php the_title(); ?><?php the_excerpt(); ?><?php the_content(); ?>
<?php endif; ?>            

?

上一篇、下一篇

<?php $next_post=get_previous_post();$prev_post=get_next_post();?>
//鏈接地址
<a href='<?php echo get_permalink( $prev_post );?>'>
//鏈接標題
<?php echo $prev_post->post_title;?></a>

?

Archive.php
文檔歸檔頁面的格式,archive.php位置:wp-content/themes/themename/archive.php;
后臺對應欄目如下:


前端:archive.php文件即對應每月內容布局

?

Search.php
位置:wp-content/themes/themename/archive.php;
wordpress自帶的搜索包含文章和page,一般需要重新限制

/**
*[只對指定的類型進行搜索]
*@param[type] $query [搜索的參數]
*/
function SearchFilter($query){
//僅搜索時
if($query->is_search){
//設定指定的文章類型,這里僅搜索文章
$query->set('post_type','post');
//指定文章和自定義類型
$query->set('post_type', array('post','custom-post-type'));
//排除指定的文章ID號
$query-->set('post__not_in', array(10,11,20,105));
//搜索指定的類型
$query->set('cat','8,15');
//搜索條件....

}
return $query;
}
add_filter('pre_get_posts','SearchFilter');

?

默認每頁文章數
在后臺的"設置"->"閱讀"中設置

翻頁

?

圖片無法上傳

在.htaccess文件中添加以下代碼

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

轉載于:https://www.cnblogs.com/catcher625/p/wordpress.html

總結

以上是生活随笔為你收集整理的wordpress主题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。