Permalinks problem - Category pages don't work

admin2025-06-07  44

I tried many different solutions to get category page for wordpress to work. Here are my settings in wordpress.

I like to have structure "domainname/name of the post/" but when I want to go to individual category page I receive an error that it doesn't exist.

If I change permalink structure from /%postname%/ to /%postname%/%category%/ everything works fine but the structure of the post is domainname/category/name of the post/ and I don't want that. mydomain/health/ doesn't work if I keep the name of the post only. It works when I change it to /%postname%/%category%/

I tried to remove . in base category and it doesn't make any difference.

These are my entries in function.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 );
?>

Any ideas?

I tried many different solutions to get category page for wordpress to work. Here are my settings in wordpress.

I like to have structure "domainname/name of the post/" but when I want to go to individual category page I receive an error that it doesn't exist.

If I change permalink structure from /%postname%/ to /%postname%/%category%/ everything works fine but the structure of the post is domainname/category/name of the post/ and I don't want that. mydomain/health/ doesn't work if I keep the name of the post only. It works when I change it to /%postname%/%category%/

I tried to remove . in base category and it doesn't make any difference.

These are my entries in function.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 );
?>

Any ideas?

Share Improve this question edited Oct 21, 2018 at 14:28 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Oct 21, 2018 at 14:27 TechuserTechuser 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I don't think you can use a period in the category base field. If you are looking to remove the category base completely there is a plugin for that - https://wordpress/plugins/remove-category-base-littlebizzy/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749243190a317557.html

最新回复(0)