真惭愧,寒假一直在打dota根本不想写东西,外面太冷又结冰又下雨 不想出去
所以更加没什么可以发上来的
主题用了一年啦,昨天想换换。又热血的折腾了一把,

首先要在主题添加文章形式的支持
<div style="background: #fdfdfd; color: black;"><span style="text-decoration: underline;">PHP语言</span>: Codee#25449</div>
<div class="source" style="font-family: None, 'Lucida Console', 'Courier New', Verdana; color: #000000; background-color: #f9f7ed;"><span style="color: #000000;">add_theme_support( 'post-formats', array( 'image', 'status'));  //增加文章形式</span></div>
image', 'status是我需要的形式,所以只添加了这两个
之后就要对主页菌下手了

<div style="background: #fdfdfd; color: black;"><span style="text-decoration: underline;">PHP语言</span>: Codee#25451</div>
<div class="source" style="font-family: None, 'Lucida Console', 'Courier New', Verdana; color: #000000; background-color: #f9f7ed;"><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">if</span>(<span style="color: #000000;">have_posts</span>()) <span style="color: #303030;">:</span> <span style="color: #008000; font-weight: bold;">while</span> (<span style="color: #000000;">have_posts</span>()) <span style="color: #303030;">:</span> <span style="color: #000000;">the_post</span>(); <span style="color: #507090;">?></span></div>
下面添加
<div style="background: #fdfdfd; color: black;"><span style="text-decoration: underline;">PHP语言</span>: Codee#25450</div>
<div class="source" style="font-family: None, 'Lucida Console', 'Courier New', Verdana; color: #000000; background-color: #f9f7ed;"><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">if</span> ( <span style="color: #000000;">has_post_format</span>( <span style="background-color: #fff0f0;">'status'</span> )) <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;"><!--这里写入 status 的格式--></span>
<span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span> <span style="color: #008000; font-weight: bold;">else</span> <span style="color: #008000; font-weight: bold;">if</span> (<span style="color: #000000;">has_post_format</span>(<span style="background-color: #fff0f0;">'gallery'</span>)) <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;">    <!--这里写入 gallery 的格式--></span><span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span><span style="color: #008000; font-weight: bold;">else</span> <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;"> <!--这里写入 普通文章 的格式--></span>
<span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span> <span style="color: #507090;">?></span></div>
这个就要根据自己的主题来了 我折腾的时候是用firebug慢慢弄的···(看到喜欢的式样就把html复制下来然后自己再慢慢改)
比如我的,弄好之后就是这个样子


<div style="background: #fdfdfd; color: black;"><span style="text-decoration: underline;">PHP语言</span>: Codee#25452</div>
<div class="source" style="font-family: None, 'Lucida Console', 'Courier New', Verdana; color: #000000; background-color: #f9f7ed;"><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">if</span> ( <span style="color: #000000;">has_post_format</span>( <span style="background-color: #fff0f0;">'status'</span> )) <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;"><div class="post-div"></span><span style="color: #000000;"><div class="toux"></span>
<span style="color: #000000;"><a href="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_permalink</span>() <span style="color: #507090;">?></span><span style="color: #000000;">" rel="bookmark" title="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_title_attribute</span>(); <span style="color: #507090;">?></span><span style="color: #000000;">"></span><span style="color: #507090;"><?php</span> <span style="color: #906030;">$author_email</span> <span style="color: #303030;">=</span> <span style="color: #000000;">get_the_author_email</span>(); <span style="color: #000000;">{</span><span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #000000;">get_avatar</span>(<span style="color: #906030;">$author_email</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">'50'</span><span style="color: #000000;">);}</span><span style="color: #507090;">?></span><span style="color: #000000;"></a></span>
<span style="color: #000000;"></div><div class="status"></span>
<span style="color: #000000;"><div class="post-content"></span>
<span style="color: #000000;"><p>于</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_time</span>(<span style="background-color: #fff0f0;">'Y/m/d'</span>); <span style="color: #507090;">?></span><span style="color: #000000;">&nbsp;</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_time</span>(<span style="background-color: #fff0f0;">'a g:i'</span>); <span style="color: #507090;">?></span><span style="color: #000000;">&nbsp;&nbsp;吐槽 │ 心情:<img src=http://xlolix.com/mood/<;/span><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #000000;">get_post_meta</span>(<span style="color: #906030;">$post</span><span style="color: #303030;">-&gt;</span><span style="color: #0000c0;">ID</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">"mood"</span><span style="color: #000000;">,</span> <span style="color: #906030;">$single</span> <span style="color: #303030;">=</span> <span style="color: #008000; font-weight: bold;">true</span>); <span style="color: #507090;">?></span><span style="color: #000000;">.png alt="</span><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #000000;">get_post_meta</span>(<span style="color: #906030;">$post</span><span style="color: #303030;">-&gt;</span><span style="color: #0000c0;">ID</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">"mood"</span><span style="color: #000000;">,</span> <span style="color: #008000; font-weight: bold;">true</span>); <span style="color: #507090;">?&gt;</span><span style="color: #000000;">" /&gt; 天气:&lt;img src=http://xlolix.com/weather/</span><span style="color: #507090;">&lt;?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #000000;">get_post_meta</span>(<span style="color: #906030;">$post</span><span style="color: #303030;">-></span><span style="color: #0000c0;">ID</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">"weather"</span><span style="color: #000000;">,</span> <span style="color: #906030;">$single</span> <span style="color: #303030;">=</span> <span style="color: #008000; font-weight: bold;">true</span>); <span style="color: #507090;">?&gt;</span><span style="color: #000000;">.png alt="</span><span style="color: #507090;">&lt;?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #000000;">get_post_meta</span>(<span style="color: #906030;">$post</span><span style="color: #303030;">-></span><span style="color: #0000c0;">ID</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">"weather"</span><span style="color: #000000;">,</span> <span style="color: #008000; font-weight: bold;">true</span>); <span style="color: #507090;">?></span><span style="color: #000000;">" /> │ <a href="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_permalink</span>() <span style="color: #507090;">?></span><span style="color: #000000;">" rel="bookmark" title="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_title</span>(); <span style="color: #507090;">?></span><span style="color: #000000;">"></span><span style="color: #507090;"><?php</span> <span style="color: #000000;">comments_number</span>(<span style="background-color: #fff0f0;">'我要发表'</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">'1 条评论'</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">'% 条评论'</span>); <span style="color: #507090;">?></span><span style="color: #000000;"></a></span>
<span style="color: #000000;"><hr><p></span><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #007020;">mb_strimwidth</span>(<span style="color: #007020;">strip_tags</span>(<span style="color: #000000;">apply_filters</span>(<span style="background-color: #fff0f0;">'the_content'</span><span style="color: #000000;">,</span> <span style="color: #906030;">$post</span><span style="color: #303030;">-></span><span style="color: #0000c0;">post_content</span><span style="color: #000000;">)),</span> <span style="color: #0000d0; font-weight: bold;">0</span><span style="color: #000000;">,</span> <span style="color: #0000d0; font-weight: bold;">300</span><span style="color: #000000;">,</span><span style="background-color: #fff0f0;">"..."</span>); <span style="color: #507090;">?></span>
<span style="color: #000000;"></p><br></span>
<span style="color: #000000;"></div><!--end post-content--></span>
<span style="color: #000000;"></div><!--end status--></span>
<span style="color: #000000;"></div></span>
<span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span> <span style="color: #008000; font-weight: bold;">else</span> <span style="color: #008000; font-weight: bold;">if</span> (<span style="color: #000000;">has_post_format</span>(<span style="background-color: #fff0f0;">'gallery'</span>)) <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;">    <!--这里写入 gallery 的格式--></span>

<span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span><span style="color: #008000; font-weight: bold;">else</span> <span style="color: #000000;">{</span> <span style="color: #507090;">?></span>
<span style="color: #000000;"><div class="post-div"></span>

<span style="color: #000000;"><div class="post-title"></span>
<span style="color: #000000;"><h2><a href="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_permalink</span>() <span style="color: #507090;">?></span><span style="color: #000000;">" rel="bookmark" title="</span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_title_attribute</span>(); <span style="color: #507090;">?></span><span style="color: #000000;">"></span><span style="color: #507090;"><?php</span> <span style="color: #000000;">the_title</span>(); <span style="color: #507090;">?></span><span style="color: #000000;"></a></span>
<span style="color: #000000;"><span class="post-edit"></span><span style="color: #507090;"><?php</span> <span style="color: #000000;">edit_post_link</span>(<span style="color: #000000;">__</span>(<span style="background-color: #fff0f0;">' (Edit) '</span><span style="color: #000000;">,</span><span style="background-color: #fff0f0;">''</span><span style="color: #000000;">,</span><span style="background-color: #fff0f0;">''</span>)); <span style="color: #507090;">?></span><span style="color: #000000;"></span><span class="post-com"></span><span style="color: #507090;"><?php</span> <span style="color: #000000;">comments_popup_link</span>(<span style="background-color: #fff0f0;">' 我要+1 '</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">' 1+ '</span><span style="color: #000000;">,</span> <span style="background-color: #fff0f0;">' %+ '</span>); <span style="color: #507090;">?></span><span style="color: #000000;"></span></h2></span>
<span style="color: #000000;"></div><!--end post-title--></span>

<span style="color: #000000;"><div class="post-thumbnail"></span>
<span style="color: #507090;"><?php</span> <span style="color: #000000;">post_thumbnail</span>();<span style="color: #507090;">?></span>
<span style="color: #000000;"></div></span>

<span style="color: #000000;"><div class="post-content"></span>
<span style="color: #000000;"><p></span><span style="color: #507090;"><?php</span> <span style="color: #008000; font-weight: bold;">echo</span> <span style="color: #007020;">mb_strimwidth</span>(<span style="color: #007020;">strip_tags</span>(<span style="color: #000000;">apply_filters</span>(<span style="background-color: #fff0f0;">'the_content'</span><span style="color: #000000;">,</span> <span style="color: #906030;">$post</span><span style="color: #303030;">-></span><span style="color: #0000c0;">post_content</span><span style="color: #000000;">)),</span> <span style="color: #0000d0; font-weight: bold;">0</span><span style="color: #000000;">,</span> <span style="color: #0000d0; font-weight: bold;">300</span><span style="color: #000000;">,</span><span style="background-color: #fff0f0;">"..."</span>); <span style="color: #507090;">?></span><span style="color: #000000;"></p></span>
<span style="color: #000000;"></div><!--end post-content--></span>

<span style="color: #000000;"></div><!--end post-div--></span>
<span style="color: #507090;"><?php</span> <span style="color: #000000;">}</span> <span style="color: #507090;">?></span>

</div>
那个图片式样没有弄好,正在找自己喜欢的样式

最后修改:2021 年 01 月 20 日 11 : 03 PM
如果觉得我的文章对你有用,请随意赞赏