Wordpress - Two different posts in two diffrent categories but with same name










0















I have created a custom post type in my wordpress. The problem is that if I have two diffrent posts in two diffrent categories but with same title e.g. TITLE one of them is TITLE-2 instead just TITLE when my permalinks are configured as %category%/TITLE. I also noticed that if I have post in CATEGORY1/TITLE1 I can just put in a browser CATEGORY2/TITLE1 and I will see this post in two categories, when I put him only in CATEGORY1. How can I solve this problem?



There is my code in function.php



function create_post_type_html5()

register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
register_taxonomy_for_object_type('post_tag', 'html5-blank');
register_post_type('html5-blank', // Register Custom Post Type
array(
'labels' => array(
'name' => __('Turnieje', 'html5blank'), // Rename these to suit
'singular_name' => __('Turnieje', 'html5blank'),
'add_new' => __('Dodaj nowy', 'html5blank'),
'add_new_item' => __('Dodaj nowy turniej', 'html5blank'),
'edit' => __('Edytuj', 'html5blank'),
'edit_item' => __('Edytuj turniej', 'html5blank'),
'new_item' => __('Dodaj nowy turniej', 'html5blank'),
'view' => __('Zobacz turniej', 'html5blank'),
'view_item' => __('Zobacz turniej', 'html5blank'),
'search_items' => __('Wyszukaj turniej', 'html5blank'),
'not_found' => __('Nie znaleziono żadnego turnieju', 'html5blank'),
'not_found_in_trash' => __('Nie znaleziono żadnego turnieju w koszu', 'html5blank')
),
'public' => true,
'hierarchical' => false, // Allows your posts to behave like Hierarchy Pages
'has_archive' => false,
'rewrite' => array('slug' => 't/%category%', 'with_front' => false),
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
), // Go to Dashboard Custom HTML5 Blank post for supports
'can_export' => true, // Allows export in Tools > Export
'taxonomies' => array(
'post_tag',
'category'
) // Add Category and Post Tags support
));


add_filter('post_type_link', 'projectcategory_permalink_structure', 10, 4);
function projectcategory_permalink_structure($post_link, $post, $leavename, $sample)
if (false !== strpos($post_link, '%category%'))
$category_type_term = get_the_terms($post->ID, 'category');
if (!empty($category_type_term))
$post_link = str_replace('%category%', array_pop($category_type_term)->
slug, $post_link);
else
$post_link = str_replace('%category%', 'uncategorized', $post_link);

return $post_link;










share|improve this question




























    0















    I have created a custom post type in my wordpress. The problem is that if I have two diffrent posts in two diffrent categories but with same title e.g. TITLE one of them is TITLE-2 instead just TITLE when my permalinks are configured as %category%/TITLE. I also noticed that if I have post in CATEGORY1/TITLE1 I can just put in a browser CATEGORY2/TITLE1 and I will see this post in two categories, when I put him only in CATEGORY1. How can I solve this problem?



    There is my code in function.php



    function create_post_type_html5()

    register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
    register_taxonomy_for_object_type('post_tag', 'html5-blank');
    register_post_type('html5-blank', // Register Custom Post Type
    array(
    'labels' => array(
    'name' => __('Turnieje', 'html5blank'), // Rename these to suit
    'singular_name' => __('Turnieje', 'html5blank'),
    'add_new' => __('Dodaj nowy', 'html5blank'),
    'add_new_item' => __('Dodaj nowy turniej', 'html5blank'),
    'edit' => __('Edytuj', 'html5blank'),
    'edit_item' => __('Edytuj turniej', 'html5blank'),
    'new_item' => __('Dodaj nowy turniej', 'html5blank'),
    'view' => __('Zobacz turniej', 'html5blank'),
    'view_item' => __('Zobacz turniej', 'html5blank'),
    'search_items' => __('Wyszukaj turniej', 'html5blank'),
    'not_found' => __('Nie znaleziono żadnego turnieju', 'html5blank'),
    'not_found_in_trash' => __('Nie znaleziono żadnego turnieju w koszu', 'html5blank')
    ),
    'public' => true,
    'hierarchical' => false, // Allows your posts to behave like Hierarchy Pages
    'has_archive' => false,
    'rewrite' => array('slug' => 't/%category%', 'with_front' => false),
    'supports' => array(
    'title',
    'editor',
    'excerpt',
    'thumbnail'
    ), // Go to Dashboard Custom HTML5 Blank post for supports
    'can_export' => true, // Allows export in Tools > Export
    'taxonomies' => array(
    'post_tag',
    'category'
    ) // Add Category and Post Tags support
    ));


    add_filter('post_type_link', 'projectcategory_permalink_structure', 10, 4);
    function projectcategory_permalink_structure($post_link, $post, $leavename, $sample)
    if (false !== strpos($post_link, '%category%'))
    $category_type_term = get_the_terms($post->ID, 'category');
    if (!empty($category_type_term))
    $post_link = str_replace('%category%', array_pop($category_type_term)->
    slug, $post_link);
    else
    $post_link = str_replace('%category%', 'uncategorized', $post_link);

    return $post_link;










    share|improve this question


























      0












      0








      0


      1






      I have created a custom post type in my wordpress. The problem is that if I have two diffrent posts in two diffrent categories but with same title e.g. TITLE one of them is TITLE-2 instead just TITLE when my permalinks are configured as %category%/TITLE. I also noticed that if I have post in CATEGORY1/TITLE1 I can just put in a browser CATEGORY2/TITLE1 and I will see this post in two categories, when I put him only in CATEGORY1. How can I solve this problem?



      There is my code in function.php



      function create_post_type_html5()

      register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
      register_taxonomy_for_object_type('post_tag', 'html5-blank');
      register_post_type('html5-blank', // Register Custom Post Type
      array(
      'labels' => array(
      'name' => __('Turnieje', 'html5blank'), // Rename these to suit
      'singular_name' => __('Turnieje', 'html5blank'),
      'add_new' => __('Dodaj nowy', 'html5blank'),
      'add_new_item' => __('Dodaj nowy turniej', 'html5blank'),
      'edit' => __('Edytuj', 'html5blank'),
      'edit_item' => __('Edytuj turniej', 'html5blank'),
      'new_item' => __('Dodaj nowy turniej', 'html5blank'),
      'view' => __('Zobacz turniej', 'html5blank'),
      'view_item' => __('Zobacz turniej', 'html5blank'),
      'search_items' => __('Wyszukaj turniej', 'html5blank'),
      'not_found' => __('Nie znaleziono żadnego turnieju', 'html5blank'),
      'not_found_in_trash' => __('Nie znaleziono żadnego turnieju w koszu', 'html5blank')
      ),
      'public' => true,
      'hierarchical' => false, // Allows your posts to behave like Hierarchy Pages
      'has_archive' => false,
      'rewrite' => array('slug' => 't/%category%', 'with_front' => false),
      'supports' => array(
      'title',
      'editor',
      'excerpt',
      'thumbnail'
      ), // Go to Dashboard Custom HTML5 Blank post for supports
      'can_export' => true, // Allows export in Tools > Export
      'taxonomies' => array(
      'post_tag',
      'category'
      ) // Add Category and Post Tags support
      ));


      add_filter('post_type_link', 'projectcategory_permalink_structure', 10, 4);
      function projectcategory_permalink_structure($post_link, $post, $leavename, $sample)
      if (false !== strpos($post_link, '%category%'))
      $category_type_term = get_the_terms($post->ID, 'category');
      if (!empty($category_type_term))
      $post_link = str_replace('%category%', array_pop($category_type_term)->
      slug, $post_link);
      else
      $post_link = str_replace('%category%', 'uncategorized', $post_link);

      return $post_link;










      share|improve this question
















      I have created a custom post type in my wordpress. The problem is that if I have two diffrent posts in two diffrent categories but with same title e.g. TITLE one of them is TITLE-2 instead just TITLE when my permalinks are configured as %category%/TITLE. I also noticed that if I have post in CATEGORY1/TITLE1 I can just put in a browser CATEGORY2/TITLE1 and I will see this post in two categories, when I put him only in CATEGORY1. How can I solve this problem?



      There is my code in function.php



      function create_post_type_html5()

      register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
      register_taxonomy_for_object_type('post_tag', 'html5-blank');
      register_post_type('html5-blank', // Register Custom Post Type
      array(
      'labels' => array(
      'name' => __('Turnieje', 'html5blank'), // Rename these to suit
      'singular_name' => __('Turnieje', 'html5blank'),
      'add_new' => __('Dodaj nowy', 'html5blank'),
      'add_new_item' => __('Dodaj nowy turniej', 'html5blank'),
      'edit' => __('Edytuj', 'html5blank'),
      'edit_item' => __('Edytuj turniej', 'html5blank'),
      'new_item' => __('Dodaj nowy turniej', 'html5blank'),
      'view' => __('Zobacz turniej', 'html5blank'),
      'view_item' => __('Zobacz turniej', 'html5blank'),
      'search_items' => __('Wyszukaj turniej', 'html5blank'),
      'not_found' => __('Nie znaleziono żadnego turnieju', 'html5blank'),
      'not_found_in_trash' => __('Nie znaleziono żadnego turnieju w koszu', 'html5blank')
      ),
      'public' => true,
      'hierarchical' => false, // Allows your posts to behave like Hierarchy Pages
      'has_archive' => false,
      'rewrite' => array('slug' => 't/%category%', 'with_front' => false),
      'supports' => array(
      'title',
      'editor',
      'excerpt',
      'thumbnail'
      ), // Go to Dashboard Custom HTML5 Blank post for supports
      'can_export' => true, // Allows export in Tools > Export
      'taxonomies' => array(
      'post_tag',
      'category'
      ) // Add Category and Post Tags support
      ));


      add_filter('post_type_link', 'projectcategory_permalink_structure', 10, 4);
      function projectcategory_permalink_structure($post_link, $post, $leavename, $sample)
      if (false !== strpos($post_link, '%category%'))
      $category_type_term = get_the_terms($post->ID, 'category');
      if (!empty($category_type_term))
      $post_link = str_replace('%category%', array_pop($category_type_term)->
      slug, $post_link);
      else
      $post_link = str_replace('%category%', 'uncategorized', $post_link);

      return $post_link;







      php wordpress






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 14 at 17:13









      Cœur

      19k9114155




      19k9114155










      asked Nov 14 '18 at 21:04









      mamfartamamfarta

      11




      11






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308693%2fwordpress-two-different-posts-in-two-diffrent-categories-but-with-same-name%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308693%2fwordpress-two-different-posts-in-two-diffrent-categories-but-with-same-name%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Syphilis

          Darth Vader #20