如何将活动类添加到wordpress:def primes(n): # sieve of eratosthenes
i, p, ps, m = 0, 3, [2], n // 2
sieve = [True] * m
while p <= n:
if sieve[i]:
ps.append(p)
for j in range((p*p-3)/2, m, p):
sieve[j] = False
i, p = i+1, p+2
return ps
def iroot(k, n): # assume n > 0
u, s, k1 = n, n+1, k-1
while u < s:
s = u
u = (k1 * u + n // u ** k1) // k
return s
def ilog(b, n): # max e where b**e <= n
lo, blo, hi, bhi = 0, 1, 1, b
while bhi < n:
lo, blo, hi, bhi = hi, bhi, hi+hi, bhi*bhi
while 1 < (hi - lo):
mid = (lo + hi) // 2
bmid = blo * pow(b, (mid - lo))
if n < bmid: hi, bhi = mid, bmid
elif bmid < n: lo, blo = mid, bmid
else: return mid
if bhi == n: return hi
return lo
def isPerfectPower(n): # x if n == x ** y, or False
for p in primes(ilog(2,n)):
x = iroot(p, n)
if pow(x, p) == n: return x
return False
生成的输出。
答案 0 :(得分:0)
您可以按照以下步骤添加这样的CSS选择器:
第1步:
将以下功能放入functions.php
function wpse_62509_current_month_selector( $link_html ) {
$current_month = date("F Y");
if ( preg_match('/'.$current_month.'/i', $link_html ) )
$link_html = preg_replace('/<li>/i', '<li class="current-month">', $link_html );
return $link_html;
}
然后在调用wp_get_archives()
add_filter( 'get_archives_link', 'wpse_62509_current_month_selector' );
您可能还想在调用wp_get_archives()
后删除过滤器,以免它与其他wp_get_archives()
或get_archives_link()
函数调用混淆。
remove_filter( 'get_archives_link', 'wpse_62509_current_month_selector' );
这将使当前月的CSS选择器。希望这对你有帮助。