Wordpress Archives - 峰哥分享 https://www.dengnz.com/tag/wordpress/ 昨天,今天,明天,每天的每天,都多懂一点点... Wed, 08 May 2019 02:14:50 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.5.4 https://www.dengnz.com/wp-content/uploads/2020/02/cropped-logo-32x32.png Wordpress Archives - 峰哥分享 https://www.dengnz.com/tag/wordpress/ 32 32 WordPress 无法升级到新版,要求FTP的问题 https://www.dengnz.com/2019/03/21/wordpress-%e6%97%a0%e6%b3%95%e5%8d%87%e7%ba%a7%e5%88%b0%e6%96%b0%e7%89%88%ef%bc%8c%e8%a6%81%e6%b1%82ftp%e7%9a%84%e9%97%ae%e9%a2%98/ https://www.dengnz.com/2019/03/21/wordpress-%e6%97%a0%e6%b3%95%e5%8d%87%e7%ba%a7%e5%88%b0%e6%96%b0%e7%89%88%ef%bc%8c%e8%a6%81%e6%b1%82ftp%e7%9a%84%e9%97%ae%e9%a2%98/?noamp=mobile#respond Wed, 20 Mar 2019 22:59:47 +0000 https://www.dengnz.com/?p=1640 昨天我把wordpress里面的更新都更新了, 更新插件的时候没有问题, 我设置了正确的文件权限。 可是要把w… 阅读更多 »WordPress 无法升级到新版,要求FTP的问题

The post WordPress 无法升级到新版,要求FTP的问题 appeared first on 峰哥分享.

]]>
昨天我把wordpress里面的更新都更新了, 更新插件的时候没有问题, 我设置了正确的文件权限。

可是要把wordpress 本身升级到 5.11 的时候, 却总是要我登录FTP。 我的文件夹的权限都是对的呀, 怎么回事呢。

最后通过搜索,我才知道, 要在 wp-config.php 里面加入

define(‘FS_METHOD’, ‘direct’);

才能够直接升级wordpress 本身, 加入这行后, 问题解决。

The post WordPress 无法升级到新版,要求FTP的问题 appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2019/03/21/wordpress-%e6%97%a0%e6%b3%95%e5%8d%87%e7%ba%a7%e5%88%b0%e6%96%b0%e7%89%88%ef%bc%8c%e8%a6%81%e6%b1%82ftp%e7%9a%84%e9%97%ae%e9%a2%98/feed/ 0
一键建站 | 一分钟拥有自己的网站 | Windows, Linux, VPS 都可以用 | 超快速建站| WordPress https://www.dengnz.com/2018/10/28/%e4%b8%80%e9%94%ae%e5%bb%ba%e7%ab%99-%e4%b8%80%e5%88%86%e9%92%9f%e6%8b%a5%e6%9c%89%e8%87%aa%e5%b7%b1%e7%9a%84%e7%bd%91%e7%ab%99-windows-linux-vps-%e9%83%bd%e5%8f%af%e4%bb%a5%e7%94%a8-%e8%b6%85/ https://www.dengnz.com/2018/10/28/%e4%b8%80%e9%94%ae%e5%bb%ba%e7%ab%99-%e4%b8%80%e5%88%86%e9%92%9f%e6%8b%a5%e6%9c%89%e8%87%aa%e5%b7%b1%e7%9a%84%e7%bd%91%e7%ab%99-windows-linux-vps-%e9%83%bd%e5%8f%af%e4%bb%a5%e7%94%a8-%e8%b6%85/?noamp=mobile#comments Sun, 28 Oct 2018 21:12:50 +0000 https://www.dengnz.com/?p=1265 本视频介绍一个一分钟快速一键建站的方法, 这个方法可以在Windows, Linux , VPS, Mac o… 阅读更多 »一键建站 | 一分钟拥有自己的网站 | Windows, Linux, VPS 都可以用 | 超快速建站| WordPress

The post 一键建站 | 一分钟拥有自己的网站 | Windows, Linux, VPS 都可以用 | 超快速建站| WordPress appeared first on 峰哥分享.

]]>

本视频介绍一个一分钟快速一键建站的方法, 这个方法可以在Windows, Linux , VPS, Mac os 等各个平台通用。 本视频还会介绍网站建好后如何发布博客, 添加菜单, 添加主页等基本wordpress 的设置。

一键建站命令:

 


docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=mypassword -d mysql:5.7.22
docker run --name test-wordpress --link test-mysql:mysql -p 8080:80 -d wordpress

-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-

The post 一键建站 | 一分钟拥有自己的网站 | Windows, Linux, VPS 都可以用 | 超快速建站| WordPress appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/10/28/%e4%b8%80%e9%94%ae%e5%bb%ba%e7%ab%99-%e4%b8%80%e5%88%86%e9%92%9f%e6%8b%a5%e6%9c%89%e8%87%aa%e5%b7%b1%e7%9a%84%e7%bd%91%e7%ab%99-windows-linux-vps-%e9%83%bd%e5%8f%af%e4%bb%a5%e7%94%a8-%e8%b6%85/feed/ 7
如何在WordPress里面发wordpress代码 https://www.dengnz.com/2018/08/29/%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e9%87%8c%e9%9d%a2%e5%8f%91wordpress%e4%bb%a3%e7%a0%81/ https://www.dengnz.com/2018/08/29/%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e9%87%8c%e9%9d%a2%e5%8f%91wordpress%e4%bb%a3%e7%a0%81/?noamp=mobile#respond Wed, 29 Aug 2018 00:29:18 +0000 http://www.dengnz.com/?p=1107 我之前发了这么一篇文章 [Wordpress] Git 主题自定义标签BBCODE Shortcode 我原来… 阅读更多 »如何在WordPress里面发wordpress代码

The post 如何在WordPress里面发wordpress代码 appeared first on 峰哥分享.

]]>
我之前发了这么一篇文章

[Wordpress] Git 主题自定义标签BBCODE Shortcode

我原来想发的是代码,可是全部被解析出来, 因为我忘了Esacpe这些特殊符号。实际上我是要想显示以下的效果。

引用: <blockquote></blockquote>\n
横线: <hr />\n
H2标签: <h2></h2>\n
H3标签: <h3></h3>\n
首行缩进: &nbsp;&nbsp;
回车: <br />
居中: <center></center>
黄字: <mark></mark>
下划线: <u></u>
代码高亮: <pre class= >\n\n</pre>
链接按钮: [dm href=][/dm]
下载按钮: [dl href=][/dl]
开源按钮: [gt href=]开源地址[/gt]
绿色通知: [v_notice][/v_notice]
红色警告: [v_error][/v_error]
黄色错误: [v_warn][/v_warn]
灰色提示: [v_tips][/v_tips]
蓝色提示: [v_blue][/v_blue]
蓝边文本: [v_act][/v_act]
BS绿色: <div class= role=></div>
BS蓝色: <div class= role=></div>
BS黄色: <div class= role=></div>
BS红色: <div class= role=></div>
绿色按钮: [gb href=][/gb]
蓝色按钮: [bb href=][/bb]
黄色按钮: [yb href=][/yb]
透明按钮: [lhb href=][/lhb]
网易云音乐: [netmusic play=][/netmusic]
视频按钮: [video play=][/video]
音频按钮: [audio play=][/audio]
隐藏收缩: [collapse title=]\n\n[/collapse]
回复可见: [reply][/reply]
登录可见: [vip][/vip]
密码可见: [secret wx=0][/secret]
弹窗下载: [fanctdl filename= filesize= href=
filedown=]这里填写的文件的辅助下载链接,A标签即可![/fanctdl]
下载面板: [dltable file= size=]这里留文件下载A标签链接,可以放多个链接[/dltable]
单页下载: [download][/download]
下一页: <!–nextpage–>
代码演示: [demo][/demo]
运行PHP: [phpcode file=]
文章内链: [neilian ids=]
文章外链: [wailian][/wailian]
无序列表: [list][/list]
付费查看: [pay point=][/pay]

但你不能直接把这些代码写在wordpress里面。 你必需把 < 换成 <, 把> 换成 >. 再把[ 换成[, ] 换成
].

最后你写入wordpress里的应该是这样的

引用: &lt;blockquote&gt;&lt;/blockquote&gt;\n
横线: &lt;hr /&gt;\n
H2标签: &lt;h2&gt;&lt;/h2&gt;\n
H3标签: &lt;h3&gt;&lt;/h3&gt;\n
首行缩进: &amp;nbsp;&amp;nbsp;
回车: &lt;br /&gt;
居中: &lt;center&gt;&lt;/center&gt;
黄字: &lt;mark&gt;&lt;/mark&gt;
下划线: &lt;u&gt;&lt;/u&gt;
代码高亮: &lt;pre class= &gt;\n\n&lt;/pre&gt;
链接按钮: &#91;dm href=&#93;&#91;/dm&#93;
下载按钮: &#91;dl href=&#93;&#91;/dl&#93;
开源按钮: &#91;gt href=&#93;开源地址&#91;/gt&#93;
绿色通知: &#91;v_notice&#93;&#91;/v_notice&#93;
红色警告: &#91;v_error&#93;&#91;/v_error&#93;
黄色错误: &#91;v_warn&#93;&#91;/v_warn&#93;
灰色提示: &#91;v_tips&#93;&#91;/v_tips&#93;
蓝色提示: &#91;v_blue&#93;&#91;/v_blue&#93;
蓝边文本: &#91;v_act&#93;&#91;/v_act&#93;
BS绿色: &lt;div class= role=&gt;&lt;/div&gt;
BS蓝色: &lt;div class= role=&gt;&lt;/div&gt;
BS黄色: &lt;div class= role=&gt;&lt;/div&gt;
BS红色: &lt;div class= role=&gt;&lt;/div&gt;
绿色按钮: &#91;gb href=&#93;&#91;/gb&#93;
蓝色按钮: &#91;bb href=&#93;&#91;/bb&#93;
黄色按钮: &#91;yb href=&#93;&#91;/yb&#93;
透明按钮: &#91;lhb href=&#93;&#91;/lhb&#93;
网易云音乐: &#91;netmusic play=&#93;&#91;/netmusic&#93;
视频按钮: &#91;video play=&#93;&#91;/video&#93;
音频按钮: &#91;audio play=&#93;&#91;/audio&#93;
隐藏收缩: &#91;collapse title=&#93;\n\n&#91;/collapse&#93;
回复可见: &#91;reply&#93;&#91;/reply&#93;
登录可见: &#91;vip&#93;&#91;/vip&#93;
密码可见: &#91;secret wx=0&#93;&#91;/secret&#93;
弹窗下载: &#91;fanctdl filename= filesize= href=
filedown=&#93;这里填写的文件的辅助下载链接,A标签即可!&#91;/fanctdl&#93;
下载面板: &#91;dltable file=
size=&#93;这里留文件下载A标签链接,可以放多个链接&#91;/dltable&#93;
单页下载: &#91;download&#93;&#91;/download&#93;
下一页: &lt;!–nextpage–&gt;
代码演示: &#91;demo&#93;&#91;/demo&#93;
运行PHP: &#91;phpcode file=&#93;
文章内链: &#91;neilian ids=&#93;
文章外链: &#91;wailian&#93;&#91;/wailian&#93;
无序列表: &#91;list&#93;&#91;/list&#93;
付费查看: &#91;pay point=&#93;&#91;/pay&#93;

我为了发上面这段代码,又二次Escape了。

The post 如何在WordPress里面发wordpress代码 appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/08/29/%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e9%87%8c%e9%9d%a2%e5%8f%91wordpress%e4%bb%a3%e7%a0%81/feed/ 0
Git 主题自定义标签BBCODE Shortcode https://www.dengnz.com/2018/08/25/git-%e4%b8%bb%e9%a2%98%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ad%bebbcode-shortcode/ https://www.dengnz.com/2018/08/25/git-%e4%b8%bb%e9%a2%98%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ad%bebbcode-shortcode/?noamp=mobile#respond Sat, 25 Aug 2018 23:41:39 +0000 https://www.dengnz.com/?p=1080 从代码里提取出来的, 方便我自己用邮件发博客哈! 引用: <blockquote></blo… 阅读更多 »Git 主题自定义标签BBCODE Shortcode

The post Git 主题自定义标签BBCODE Shortcode appeared first on 峰哥分享.

]]>
从代码里提取出来的, 方便我自己用邮件发博客哈!

引用: <blockquote></blockquote>\n
横线: <hr />\n
H2标签: <h2></h2>\n
H3标签: <h3></h3>\n
首行缩进: &nbsp;&nbsp;
回车: <br />
居中: <center></center>
黄字: <mark></mark>
下划线: <u></u>
代码高亮: <pre class= >\n\n</pre>
链接按钮: [dm href=][/dm]
下载按钮: [dl href=][/dl]
开源按钮: [gt href=]开源地址[/gt]
绿色通知: [v_notice][/v_notice]
红色警告: [v_error][/v_error]
黄色错误: [v_warn][/v_warn]
灰色提示: [v_tips][/v_tips]
蓝色提示: [v_blue][/v_blue]
蓝边文本: [v_act][/v_act]
BS绿色: <div class= role=></div>
BS蓝色: <div class= role=></div>
BS黄色: <div class= role=></div>
BS红色: <div class= role=></div>
绿色按钮: [gb href=][/gb]
蓝色按钮: [bb href=][/bb]
黄色按钮: [yb href=][/yb]
透明按钮: [lhb href=][/lhb]
网易云音乐: [netmusic play=][/netmusic]
视频按钮: [video play=][/video]
音频按钮: [audio play=][/audio]
隐藏收缩: [collapse title=]\n\n[/collapse]
回复可见: [reply][/reply]
登录可见: [vip][/vip]
密码可见: [secret wx=0][/secret]
弹窗下载: [fanctdl filename= filesize= href= filedown=]这里填写的文件的辅助下载链接,A标签即可![/fanctdl]
下载面板: [dltable file= size=]这里留文件下载A标签链接,可以放多个链接[/dltable]
单页下载: [download][/download]
下一页: <!–nextpage–>
代码演示: [demo][/demo]
运行PHP: [phpcode file=]
文章内链: [neilian ids=]
文章外链: [wailian][/wailian]
无序列表: [list][/list]
付费查看: [pay point=][/pay]

The post Git 主题自定义标签BBCODE Shortcode appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/08/25/git-%e4%b8%bb%e9%a2%98%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a0%87%e7%ad%bebbcode-shortcode/feed/ 0
Add or update font-awesome for wordpress theme https://www.dengnz.com/2018/07/19/add-or-update-font-awesome-for-wordpress-theme/ https://www.dengnz.com/2018/07/19/add-or-update-font-awesome-for-wordpress-theme/?noamp=mobile#respond Thu, 19 Jul 2018 10:19:28 +0000 https://www.dengnz.com/?p=832 I am using a wordpress theme which uses an old version … 阅读更多 »Add or update font-awesome for wordpress theme

The post Add or update font-awesome for wordpress theme appeared first on 峰哥分享.

]]>
I am using a wordpress theme which uses an old version of font-awesome. And I noticed that the font-awesome style are embed in the main style.css file. I cannot upgrade font-awesome separately.

The fontawesome-webfont.svg file is seperate and has version number 1.0.

To make use of the new version of font-awesome. I don’t need to touch the old version. All I need to do is adding the following style into my theme.

To add the new 5.1.1 fontawesome to your theme is easy.

Add this code into the header.php of your theme in head tags

&amp;lt;link rel="stylesheet" href="
&amp;lt;a href="https://use.fontawesome.com/releases/v5.1.1/css/all.css"&amp;gt;use.fontawesome.com/releases/v5.1.1/css/all.css&amp;lt;/a&amp;gt;"
integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ"
crossorigin="anonymous"&amp;gt;

Then you can start using the latest font-awesome icons. Try this<i class=”fab fa-youtube”></i> in your posts, you can also use font-awesome in
your menu text.

 

 

By adding a new style sheet will certainly impact your website’s performance, because browsers has one more style sheet to load before rendering. But this method will not impact much for the server load as the font-awesome style is hosted by font-awesome CDN.

The post Add or update font-awesome for wordpress theme appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/19/add-or-update-font-awesome-for-wordpress-theme/feed/ 0
Bulk Remove WordPress ‘Uncategorized’ Category from posts using phpMyAdmin https://www.dengnz.com/2018/07/18/bulk-remove-wordpress-uncategorized-category-from-posts-using-phpmyadmin/ https://www.dengnz.com/2018/07/18/bulk-remove-wordpress-uncategorized-category-from-posts-using-phpmyadmin/?noamp=mobile#respond Wed, 18 Jul 2018 02:11:22 +0000 https://www.dengnz.com/?p=777 We can bulk apply categories to posts from wordpress po… 阅读更多 »Bulk Remove WordPress ‘Uncategorized’ Category from posts using phpMyAdmin

The post Bulk Remove WordPress ‘Uncategorized’ Category from posts using phpMyAdmin appeared first on 峰哥分享.

]]>
We can bulk apply categories to posts from wordpress portal as shown below.


Unfortunately, we cannot bulk remove a category from posts. In my case, my default category is ‘Uncategorized’. Once I bulk assign category to my posts, I would like to remove these posts from ‘Uncategorized’. This cannot be done through wordpress portal easily, although there is a workaround.
 
Today, I will introduce a quick way to do this.

[v_error]Warning: Before following this article, make sure you have backup your database and get ready to rollback.[/v_error]

First thing that we want to do is finding out the term_taxonomy_id of ‘Uncategorized’. In my case,’Uncategorized’ has a term_id of 1.

Then we can find out that the term_taxonomy_id of ‘Uncategorized’ is 1 as well.

Now, let’s leave term_taxonomy_id along, we will need it later. The second thing we need to do is finding out the posts that contains at least 2 categories. Because we don’t want to touch the posts that only has ‘Uncategorized’ category.
 
Start a phpMyAdmin service. In my case, I use docker to create a phpMyAdmin server. You will need to know your mysql server login info. And also make sure your public IP is in your mysql server’s white list.
 
docker run –name myadmin2 –rm -e PMA_HOST=yourSqlServer -p 8083:80 phpmyadmin/phpmyadmin

 

docker run --name myadmin --rm --link wp-mysql:db  --network wp-net  --network-alias myadmin-host  -p 8083:80 phpmyadmin/phpmyadmin

Then login to phpMyAdmin and select the wordpress database. In my case, the PhpMyAdmin address is http://localhost:8083
Execute the following sql code to find out the post IDs that contains more than 1 categories.

 

-- Show WP posts ID that contains multipal categories
select object_id, count(*) as numberOfCategories
from wp_term_relationships a
join wp_term_taxonomy b
on a.term_taxonomy_id = b.term_taxonomy_id
where b.taxonomy = 'category'
group by a.object_id
having numberOfCategories > 1

 

Once executed, you will see all the object_id that contains more than 1 categories.
 
 

If you want to see the posts detail, you can use the following sql query.

-- Show WP posts that contains multipal categories
select * from wp_posts c
join 
(select object_id, count(*) as numberOfCategories
from wp_term_relationships a
join wp_term_taxonomy b
on a.term_taxonomy_id = b.term_taxonomy_id
where b.taxonomy = 'category'
group by a.object_id
having numberOfCategories > 1) Ids
on c.ID = Ids.object_id

Check the output and make sure these are the posts that you want to remove ‘Uncategorized’ from. Note that other posts that do not contain  ‘Uncategorized’  will be displayed as well as long as they have more than 1 categories. Don’t worry, we will not touch them.

If everything look all right, we can now start our deletion. But wait, let’s do one more check. Execute the following sql query to show all the entries that will be deleted from wp_term_relationships table.  Note that the last line And t1.term_taxonomy_id = 1 is important, don’t miss it. And the number 1 here is the one we found in our first step.

select * 
FROM wp_term_relationships t1
JOIN 
    (select object_id, count(*) as numberOfCategories
    from wp_term_relationships a
    join wp_term_taxonomy b
    on a.term_taxonomy_id = b.term_taxonomy_id
    where b.taxonomy = 'category'
    group by a.object_id
    having numberOfCategories > 1) Ids
ON t1.object_id = Ids.object_id
And t1.term_taxonomy_id = 1

Looks good to you? Now it’s the core operation, everything we execute before is select query that does not change the database.  They are just for you to check if everything is OK. You don’t even need to execute them. Now come to the real cool thing.
This operation will perform the deletion. You cannot undo this. Let’s change select * to delete t1 like the following:

delete t1 
FROM wp_term_relationships t1
JOIN 
    (select object_id, count(*) as numberOfCategories
    from wp_term_relationships a
    join wp_term_taxonomy b
    on a.term_taxonomy_id = b.term_taxonomy_id
    where b.taxonomy = 'category'
    group by a.object_id
    having numberOfCategories > 1) Ids
ON t1.object_id = Ids.object_id
And t1.term_taxonomy_id = 1 

Click the go button to execute the query, you will get some thing like this:

Done!
Check your wordpress portable to see if everything is as expected. If not, rollback your DB.

The post Bulk Remove WordPress ‘Uncategorized’ Category from posts using phpMyAdmin appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/18/bulk-remove-wordpress-uncategorized-category-from-posts-using-phpmyadmin/feed/ 0
WordPress Git 主题英文断字问题 https://www.dengnz.com/2018/07/17/wordpress-git-%e4%b8%bb%e9%a2%98%e8%8b%b1%e6%96%87%e6%96%ad%e5%ad%97%e9%97%ae%e9%a2%98/ https://www.dengnz.com/2018/07/17/wordpress-git-%e4%b8%bb%e9%a2%98%e8%8b%b1%e6%96%87%e6%96%ad%e5%ad%97%e9%97%ae%e9%a2%98/?noamp=mobile#respond Tue, 17 Jul 2018 22:47:39 +0000 https://www.dengnz.com/?p=749 Git 主题是国人开发的主题, 所以用的是中文长用的断字样式规则。 但是我有时候也会写英文的博客, 英文被断字… 阅读更多 »WordPress Git 主题英文断字问题

The post WordPress Git 主题英文断字问题 appeared first on 峰哥分享.

]]>
Git 主题是国人开发的主题, 所以用的是中文长用的断字样式规则。 但是我有时候也会写英文的博客, 英文被断字以后读起来非常的不舒服。 如下, Android 这个单词被断了。

看看样式表发现是因为 .article-content 里面有一个样式
word-break: break-all;
​
把这个样式改成 
work-break: break-word; 
就可以解决问题。

​更好的方法是使用子主题来 override 之前的样式。 就像我前一篇博客提到的。 


在子主题的样式里加上这么一行


问题解决, 而且父主题可以正常升级, 之前的修改不会因为父主题升级而消失。

The post WordPress Git 主题英文断字问题 appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/17/wordpress-git-%e4%b8%bb%e9%a2%98%e8%8b%b1%e6%96%87%e6%96%ad%e5%ad%97%e9%97%ae%e9%a2%98/feed/ 0
Create a child theme for wordpress https://www.dengnz.com/2018/07/17/create-a-child-theme-for-wordpress/ https://www.dengnz.com/2018/07/17/create-a-child-theme-for-wordpress/?noamp=mobile#respond Tue, 17 Jul 2018 04:15:36 +0000 http://www.dengnz.com/?p=742 Sometimes, you need to customize your wordpress theme t… 阅读更多 »Create a child theme for wordpress

The post Create a child theme for wordpress appeared first on 峰哥分享.

]]>

Sometimes, you need to customize your wordpress theme to fit your needs. For example, I have to modify the header.php file to include my google ad code. I also found some bugs in my theme and I needed to fix them by modifying the code.

The problem of modifying the original theme is that all your changes will be lost once theme updated. To overcome this problem, a child theme can be used.

It’s pretty easy to create a child theme. All your need is creating one directory and two files.

First, create a new folder in your themes folder. The name of folder is not important, but the suggested pattern is orginalThemeName-child.

Then copy the style.css file from your parent theme into the child theme folder. Open the style.css file and delete everything except the header.

Then update the theme name, and add a new template line. In my case, I changed the Theme Name to Git-child, and added a new line “Template: git” after Author URI line. The parent theme directory of this theme is git.

The content of my child theme style looks:

/*
Theme Name: Git-child
Theme URI: http://googlo.me/archives/3589.html
Description: Git主题,由云落基于yusi主题基础上二次开发的一款功能强大具有超强自定义能力的主题。代码已开源至<a href="https://coding.net/u/googlo/p/Git/git" target="_blank" rel="noopener">Coding</a>,欢迎斧正!
Author: 云落
Author URI: http://googlo.me/
Template: git
Version: 9.3.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
代码高亮,强大,免费主题,CMS主题,卡片式,图片主题,在线更新
*/

Now create a new file call function.php with following content.  You need to change the value of
$parent_style to match your parent theme. In my case, it’s style. You can find it from the parent’s function.php file, looking for the lines contains
wp_enqueue_style.

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_uri() );$
    
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

Now your child-theme is ready to be used. It will be exactly same as your parent theme. You can find and apply your new child theme from wordpress’s theme panel.

But we are not making a copy theme doing the same thing. We want to make some changes without touching the parent theme.

The files under child theme directory will overwrite the same file under the parent directory. So, copy the header.php file from the parent theme folder to the child-theme folder, then update the child header.php to include google ad code. You will still need to manually update this file if next version of the parent theme changes the parent header.php file. But this rarely happen. In most case, you can safely update the parent theme.

If you are still worried, you can redundant your parent theme and child theme, activate it. Then update the original copy first, use the live preview feature to make sure everything is good before applying the new theme. You can also compare the updated copy with the old copy to find out if header.php has been changed.

If you want to overwrite CSS, you can overwrite it in the child’s style.css file.

The post Create a child theme for wordpress appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/17/create-a-child-theme-for-wordpress/feed/ 0
WordPress Git 主题BLOG侧边栏不见的问题 https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98blog%e4%be%a7%e8%be%b9%e6%a0%8f%e4%b8%8d%e8%a7%81%e7%9a%84%e9%97%ae%e9%a2%98/ https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98blog%e4%be%a7%e8%be%b9%e6%a0%8f%e4%b8%8d%e8%a7%81%e7%9a%84%e9%97%ae%e9%a2%98/?noamp=mobile#respond Fri, 13 Jul 2018 08:15:13 +0000 http://www.dengnz.com/?p=715 WordPress 应用主题之前利用Live preview 的功能检查一下是个好主意。 我通过这个查出了一个… 阅读更多 »WordPress Git 主题BLOG侧边栏不见的问题

The post WordPress Git 主题BLOG侧边栏不见的问题 appeared first on 峰哥分享.

]]>
WordPress 应用主题之前利用Live preview 的功能检查一下是个好主意。 我通过这个查出了一个图片不能显示的问题, 然后修复了一个引起这样的权限问题。
然后我从 Preview 的地方 active 了这个主题 

然后问题就来了, 侧边栏不见了, 在preview 的时候是有的

要解决这个问题, 先启用另一个主题, 然后从有主题设置界面直接启用主题 

​侧边栏出现了
​

​我并没有查出具体的原因, 但这是一个解决问题的快速方法。​



The post WordPress Git 主题BLOG侧边栏不见的问题 appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98blog%e4%be%a7%e8%be%b9%e6%a0%8f%e4%b8%8d%e8%a7%81%e7%9a%84%e9%97%ae%e9%a2%98/feed/ 0
WordPress Git 主题无法显示缩略图 https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98%e6%97%a0%e6%b3%95%e6%98%be%e7%a4%ba%e7%bc%a9%e7%95%a5%e5%9b%be/ https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98%e6%97%a0%e6%b3%95%e6%98%be%e7%a4%ba%e7%bc%a9%e7%95%a5%e5%9b%be/?noamp=mobile#respond Fri, 13 Jul 2018 08:13:27 +0000 http://www.dengnz.com/?p=712 直接输入图片地址发现是权限问题 解决的方法就是把cache 文件夹的owner 改成 www-data, 而且… 阅读更多 »WordPress Git 主题无法显示缩略图

The post WordPress Git 主题无法显示缩略图 appeared first on 峰哥分享.

]]>
直接输入图片地址发现是权限问题

解决的方法就是把cache 文件夹的owner 改成 www-data, 而且还必需给777权限
root@d314697e9a0d:/var/www/html/wp-content/themes/git# chmod 777 cache/
/var/www/html/wp-content/themes/git# chown -R www-data:www-data cache


The post WordPress Git 主题无法显示缩略图 appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/07/13/wordpress-git-%e4%b8%bb%e9%a2%98%e6%97%a0%e6%b3%95%e6%98%be%e7%a4%ba%e7%bc%a9%e7%95%a5%e5%9b%be/feed/ 0