我尝试了许多不同的解决方案来获得wordpress的分类页面。以下是我在wordpress中的设置。
我喜欢有“domainname.com/name of the post/”的结构,但当我想转到个人分类页面时,我收到一个错误,它不存在。
如果我将permalink结构从/%postname%/更改为/%postname%/%category%/一切正常,但帖子的结构是domainname。com/类别/帖子名称/我不想这样。mydomain。如果我只保留帖子的名称,com/health/not work。当我将其更改为/%postname%/%类别%/
我试图删除。在基本类别中,这没有任何区别。
这些是我在函数中的条目。php
<?php
function comment_reply_text( $link ) {
$link = str_replace( \'Reply\', \'Odgovori\', $link );
return $link;
}
add_filter( \'comment_reply_link\', \'comment_reply_text\' );
?>
<?php
function catch_that_image() {
global $post, $posts;
$first_img = \'\';
ob_start();
ob_end_clean();
$output = preg_match_all(\'/<img.+src=[\\\'"]([^\\\'"]+)[\\\'"].*>/i\', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}
?>
<?php
function wpsites_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( \'posts_per_page\', 10 ); }
}
add_action( \'pre_get_posts\', \'wpsites_query\' );
?>
<?php
function custom_excerpt($word_count_limit) {
$content = wp_strip_all_tags(get_the_content() , true );
echo wp_trim_words($content, $word_count_limit);
}
?>
<?php
add_filter( \'term_link\', function($termlink){ return str_replace(\'/./\', \'.\', $termlink); }, 10, 1 );
?>
有什么想法吗?