开发者 | Alphawolf |
---|---|
更新时间 | 2023年11月7日 00:23 |
捐献地址: | 去捐款 |
PHP版本: | 3.7 及以上 |
WordPress版本: | 6.3.99 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
You can add the archive to any post/page by using shortcode. See Usage for examples, available parameters and more.
Just use the filter sya_the_title
. Example: Add the following to your theme's functions.php
:
`
add_filter( 'sya_the_title', 'my_sya_filter_title', 10, 2 );
function my_sya_filter_title( $title, $id ) {
return $id . ' - ' . $title;
}
`
Just use the filter sya_postlink
. Example: Add the following to your theme's functions.php
:
`
add_filter( 'sya_postlink', 'sya_modify_postlinks', 10, 3 );
function sya_modify_postlinks( $link_html, $post ) {
$dom = new DOMDocument();
$dom->loadHtml($link_html);
$xpath = new DOMXPath($dom);
$link = $xpath->query("//a")->item(0);
$link_classes = explode(' ', $link->getAttribute('class'));
$link_classes[] = 'postyear-' . $post->post_year;
$link->setAttribute('class', implode(' ', $link_classes));
return $dom->saveHTML();
}
`
This will add a CSS class with the post year to the post links.
Just use the filter sya_the_authors
. Example: Add the following to your theme's functions.php
:
`
if( function_exists('get_coauthors') ) {
add_filter( 'sya_the_authors', 'my_sya_filter_authors', 10, 2 );
function my_sya_filter_authors( $author, $post ) {
$coauthors = get_coauthors( $post->ID );
$authorsCollection = array();
foreach( $coauthors as $coauthor ) {
if( $coauthor->display_name ) {
$authorsCollection[] = $coauthor->display_name;
}
}
return implode(', ', $authorsCollection);
}
}
`
Just use the filter sya_categories
. Example: Add the following to your theme's functions.php
:
function sya_child_categories( $sya_categories ) { return array_filter($sya_categories, function($v, $k) { return get_category( $k )->parent > 0; }, ARRAY_FILTER_USE_BOTH); } add_filter( 'sya_categories', 'sya_child_categories', 10, 3 );
Just use the filter sya_get_posts
that allows you to query for literally anything using WP_Query
parameters. Add the following snippets to your theme's functions.php
.
Display posts that have "either" of these tags
add_filter( 'sya_get_posts', function() { return array( 'tag' => 'bread,baking' ); });
Display posts that match the search term "keyword"
add_filter( 'sya_get_posts', function() { return array( 's' => 'keyword' ); });
Display only password protected posts
add_filter( 'sya_get_posts', function() { return array( 'has_password' => true ); });
Display only 10 posts
add_filter( 'sya_get_posts', function() { return array( 'numberposts' => 10 ); });
Display posts tagged with bob, under people custom taxonomy
add_filter( 'sya_get_posts', function() { return array( 'tax_query' => array( array( 'taxonomy' => 'people', 'field' => 'slug', 'terms' => 'bob', ) ) ); });
Display posts from several custom taxonomies
add_filter( 'sya_get_posts', function() { return array( 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'movie_genre', 'field' => 'slug', 'terms' => array( 'action', 'comedy' ), ), array( 'taxonomy' => 'actor', 'field' => 'term_id', 'terms' => array( 103, 115, 206 ), 'operator' => 'NOT IN', ), ) ); });
Display posts that are in the quotes category OR have the quote format
add_filter( 'sya_get_posts', function() { return array( 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'quotes' ), ), array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-quote' ), ), ) ); });
Display posts that are in the quotes category OR both have the quote post format AND are in the wisdom category
add_filter( 'sya_get_posts', function() { return array( 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'quotes' ) ), array( 'relation' => 'AND', array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-quote' ) ), array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'wisdom' ), ) ) ) ); });
Configuration? Parameters? Head over here
sya_yearanchor
and sya_postlink
the_title
filtersya_categories
and sya_tags
sya_get_posts
so you can query for literally anything using WP_Query
parameters! See examples heresya_the_authors
so you can filter the post's authors listing before output (e.g. support for the Co-Authors Plus plugin)sya_the_title
so you can filter the post's title before output<?php simpleYearlyArchive(); ?>
(sorry!)[SimpleYearlyArchive type="1249077600-1280527200"]
where start and end point are UNIX timestamps[SimpleYearlyArchive ... dateformat="d/m"]
apply_filters('sya_archive_output', $output)
filter hook so you can alter the HTML output before it's being returnedinclude
parameter allowing to include categories instead of only excluding them