固定链接问题-类别页面不起作用

时间:2018-10-21 作者:Techuser

我尝试了许多不同的解决方案来获得wordpress的分类页面。以下是我在wordpress中的设置。enter image description here

我喜欢有“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 );
?>
有什么想法吗?

1 个回复
SO网友:Danny Cooper

我认为您不能在类别基字段中使用句点。如果您希望完全删除类别库,则有一个插件可用于-https://wordpress.org/plugins/remove-category-base-littlebizzy/

结束

相关推荐

Let me choose permalinks

我需要选择一个叫做“mysite”的永久链接。com/1418”,但wordpress不断在永久链接中添加“-2”。通常这意味着我已经有了一个名为“相同”的页面,它位于垃圾箱或其他地方。但这里的情况似乎并非如此。我尝试在设置中重置永久链接,这也没有帮助。我如何使用数字作为页面名称permalink,而不用wordpress在permalink中添加“-2”。