regionhalland / region-halland-plugin-news-archive-taxonomi-category
创建包含分类的新闻文章类型,并使用archive.php来显示新闻
v2.12.0
2022-11-02 06:37 UTC
This package is auto-updated.
Last update: 2024-09-09 11:34:03 UTC
README
如何使用Region Halland的插件"RhNewsArchiveTaxonomiCategory"
以下是使用"RhNewsArchiveTaxonomiCategory"插件的操作说明。
使用范围
此插件创建了一个包含分类的"news"文章类型,并使用"archive.php"来显示新闻。注意!如果您还安装了插件https://github.com/RegionHalland/region-halland-use-taxonomy-category-on-page.git,即能够在页面上使用分类,那么您还可以使用"get_region_halland_page_news_taxonomi_category()"函数来获取与页面/新闻分类节点匹配的新闻。
许可证模型
此插件使用GPL-3.0许可证模型。您可以通过随附的文件了解更多关于此许可证模型的信息。
LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNewsArchiveTaxonomiCategory?path=%2FLICENSE&version=GBmaster)
安装和激活
A) Hämta pluginen via Git eller läs in det med Composer
B) Installera Region Hallands plugin i Wordpress plugin folder
C) Aktivera pluginet inifrån Wordpress admin
通过Git获取插件
git clone https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNewsArchiveTaxonomyCategory
通过composer导入插件
这两个部分需要添加到您的composer文件中
Repositories = 插件存储的位置,在此例中为github
"repositories": [
{
"type": "vcs",
"url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNewsArchiveTaxonomyCategory"
},
],
Require = 指定您想使用的插件版本,在此例中为1.0.0
注意!确保您获取的是最新版本。
"require": {
"regionhalland/region-halland-news-archive-taxonomi-category": "1.0.0"
},
通过"Blade"获取所有分类并在"archive.php"中显示
@if(function_exists('get_region_halland_news_archive_taxonomi_category_categories'))
@php($categories = get_region_halland_news_archive_taxonomi_category_categories('Visa alla nyheter'))
<ul>
@foreach($categories as $category)
<li>
<a href="{{ $category['link'] }}">{{ $category['name'] }}</a>
</li>
@endforeach
</ul>
@endif
数组的示例
array (size=6)
0 =>
array (size=2)
'name' => string 'Visa alla nyheter' (length=17)
'link' => string 'http://exempel.se/nyheter/' (length=26)
1 =>
array (size=2)
'name' => string 'Lorem ipsum' (length=11)
'link' => string 'http://exempel.se/nyheter/?filter[category]=okategoriserat' (length=58)
2 =>
array (size=2)
'name' => string 'Lorem ipsum mit' (length=15)
'link' => string 'http://exempel.se/nyheter/?filter[category]=lorem-ipsum-mit' (length=61)
3 =>
array (size=2)
'name' => string 'Alqura met balum' (length=16)
'link' => string 'http://exempel.se/nyheter/?filter[category]=alqura-met-balum' (length=54)
通过"Blade"显示所有文章,包括所有分类
@if(function_exists('get_region_halland_news_archive_taxonomi_category_filter'))
@php($myPosts = get_region_halland_news_archive_taxonomi_category_filter())
@foreach($myPosts as $post)
<a href="{{ $post['permalink'] }}">
<h2>{{ $post['title'] }}</h2>
</a>
<p>{{ $post['ingress'] }}</p>
<span>Publicerad: {{ $post['date'] }}</span>
<p>{{ $post['content'] }}</p>
@foreach($post['terms'] as $term)
<a href="{{ $term['link'] }}">{{ $term['name'] }}</a>
@endforeach
@endforeach
@endif
数组的示例
array (size=2)
0 =>
array (size=5)
'permalink' => string 'http://exempel.se/nyheter/lorem-ipsum/' (length=38)
'title' => string 'Lorem ipsum' (length=11)
'content' => string 'Vestibulum ante ipsum primis in faucibus' (length=40)
'ingress' => string 'Lorem ipsum' (length=11)
'date' => string '2018-10-01' (length=10)
'terms' =>
array (size=1)
0 =>
array (size=2)
'name' => string 'In nisl neque' (length=10)
'link' => string 'http://exempel.se/nyheter/?filter[category]=in-nisl-neque' (length=57)
1 =>
array (size=5)
'permalink' => string 'http://exempel.se/nyheter/ellentesque-habitant-morbi/' (length=52)
'title' => string 'Ellentesque habitant morbi' (length=26)
'content' => string 'Donec maximus purus justo' (length=25)
'ingress' => string 'Lorem ipsum' (length=11)
'date' => string '2018-09-24' (length=10)
'terms' =>
array (size=2)
0 =>
array (size=2)
'name' => string 'Morbi id eleifend' (length=17)
'link' => string 'http://exempel.se/nyheter/?filter[category]=morbi-id-eleifend' (length=61)
1 =>
array (size=2)
'name' => string 'Donec eros diam' (length=15)
'link' => string 'http://exempel.se/nyheter/?filter[category]=donec-eros-diam' (length=59)
通过"Blade"显示所有分类在任意页面上的文章,例如示例中的2篇文章
@if(function_exists('get_region_halland_news_archive_taxonomi_category_items'))
@php($news = get_region_halland_news_archive_taxonomi_category_items(2))
@if(isset($news) && !empty($news))
@foreach ($news as $myNews)
<a href="{{ $myNews->url }}">
<h2>{{ $myNews->post_title }}</h2>
</a>
<p>{{ $myNews->ingress }}</p>
<span>Publicerad: {{ $myNews->date }}</span>
<p>{!! $myNews->post_content !!}</p>
@foreach($myNews->terms as $term)
<a href="{{ $term['link'] }}">{{ $term['name'] }}</a>
@endforeach
@endforeach
@endif
@endif
数组的示例
array (size=2)
0 =>
object(WP_Post)[8604]
public 'ID' => int 6978
public 'post_author' => string '174' (length=3)
public 'post_date' => string '2018-11-20 10:06:18' (length=19)
public 'post_date_gmt' => string '2018-11-20 08:06:18' (length=19)
public 'post_content' => string 'Lorem ipsum' (length=11)
public 'post_title' => string 'Lorem ipsum dolares' (length=19)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'lorem-ipsum-dolares' (length=19)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2018-11-20 10:06:53' (length=19)
public 'post_modified_gmt' => string '2018-11-20 08:06:53' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://exempel.se/?post_type=news&p=6978' (length=45)
public 'menu_order' => int 0
public 'post_type' => string 'news' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'url' => string 'http://exempel.se/lorem-ipsum-dolares/' (length=38)
public 'image' => string '' (length=0)
public 'image_url' => boolean false
public 'date' => string '2018-11-20' (length=10)
public 'ingress' => string 'Lorem ipsum' (length=11)
public 'terms' =>
array (size=1)
0 =>
array (size=3)
'name' => string 'Quertum alares' (length=14)
'link' => string 'http://exempel.se/nyheter/?filter[category]=quertum-alares' (length=34)
1 =>
object(WP_Post)[8606]
public 'ID' => int 6966
public 'post_author' => string '174' (length=3)
public 'post_date' => string '2018-11-19 14:15:49' (length=19)
public 'post_date_gmt' => string '2018-11-19 12:15:49' (length=19)
public 'post_content' => string 'Vestibulum semper rhoncus' (length=25)
public 'post_title' => string 'Phasellus tristique dignissim' (length=28)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'phasellus-tristique-dignissim' (length=28)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2018-11-19 14:17:09' (length=19)
public 'post_modified_gmt' => string '2018-11-19 12:17:09' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://exempel.se/?post_type=news&p=6966' (length=42)
public 'menu_order' => int 0
public 'post_type' => string 'news' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'url' => string 'http://exempel.se/nyheter/phasellus-tristique-dignissim/' (length=55)
public 'image' => string '' (length=0)
public 'image_url' => boolean false
public 'date' => string '2018-11-19' (length=10)
public 'ingress' => string 'Lorem ipsum' (length=11)
public 'terms' =>
array (size=1)
0 =>
array (size=3)
'name' => string 'Marumel domir' (length=13)
'link' => string 'http://exempel.se/nyheter/?filter[category]=marumelddomir' (length=58)
通过"Blade"显示所有分类在相关页面/新闻上的文章。
@if(function_exists('get_region_halland_page_news_taxonomi_category'))
@php($pageNews = get_region_halland_page_news_taxonomi_category())
@if(isset($pageNews) && !empty($pageNews))
@foreach ($pageNews as $myNews)
<a href="{{ $myNews['permalink'] }}">
<h2>{{ $myNews['title'] }}</h2>
</a>
<p>{{ $myNews['ingress'] }}</p>
<span>Publicerad: {{ $myNews['date'] }}</span>
<p>{!! $myNews['content'] !!}</p>
@foreach($myNews['terms'] as $term)
<a href="{{ $term['link'] }}">{{ $term['name'] }}</a>
@endforeach
@endforeach
@endif
@endif
数组的示例
array (size=2)
0 =>
array (size=8)
'ID' => string '102' (length=3)
'title' => string 'Lorem ipsum' (length=11)
'permalink' => string 'http://exempel.se/nyheter/lorem-ipsum/' (length=38)
'date' => string '2019-02-11' (length=10)
'content' => string 'Vestibulum ante ipsum primis in faucibus' (length=40)
'ingress' => string 'Lorem ipsum' (length=11)
'image' => string '' (length=0)
'image_url' => boolean false
'terms' =>
array (size=2)
0 =>
array (size=2)
'name' => string 'Morbi id eleifend' (length=17)
'link' => string 'http://exempel.se/nyheter/?filter[category]=morbi-id-eleifend' (length=61)
1 =>
array (size=8)
'ID' => string '124' (length=3)
'title' => string 'Ellentesque habitant morbi' (length=26)
'permalink' => string 'http://exempel.se/nyheter/ellentesque-habitant-morbi/' (length=52)
'date' => string '2019-03-05' (length=10)
'content' => string 'Donec maximus purus justo' (length=25)
'image' => string '' (length=0)
'image_url' => boolean false
'terms' =>
array (size=2)
0 =>
array (size=2)
'name' => string 'Morbi id eleifend' (length=17)
'link' => string 'http://exempel.se/nyheter/?filter[category]=morbi-id-eleifend' (length=61)
通过"Blade"在单篇文章页面上显示摘要
<p>{{ get_region_halland_page_news_taxonomi_category_ingress() }}</p>
通过"Blade"在单篇文章页面上显示新闻是否已超过1年
@php($outdated = get_region_halland_news_archive_taxonomi_category_outdated())
@if($outdated == 1)
<p>Detta är en nyhet som är ädre än 1 år</p>
@endif
版本历史
2.12.0
- 只显示超过1年的新闻
- 显示新闻是否超过1年的功能
1.9.0
- 添加了通过Packagist发布管道
- 调整了composer名称
1.8.0
- 将显示首页新闻的复选框更改为true/false
- 重构了首页新闻获取功能
1.7.0
- 添加了用于在模板页面上获取新闻的计数函数
1.6.0
- 添加了显示首页新闻的复选框
- 添加了获取选定新闻的新功能
1.5.0
- 调整了权限
1.4.0
- 更新了许可证模型信息
- 附加了许可证模型文件
1.3.3
- 修复了错误。只为相关文章获取post_type 'news'。
1.3.2
- 只获取了10条新闻而不是所有新闻。
1.3.1
- 调整了摘要的ID
1.3.0
- 添加了摘要字段
- 添加了在单篇文章页面上获取摘要的功能
- 在所有列表获取中添加了摘要字段
- 调整了过滤器功能中的URL,从?filter[category]更改为?category
1.2.2
- 每页默认显示4条新闻
- 允许用户自行选择每页新闻的数量
- 最新发布的内容排在最上面
1.2.1
- 改进了README
1.2.0
- 添加了相关页面/新闻功能
1.1.0
- 添加了权限
1.0.0
- 第一个版本