{"id":5197,"date":"2017-08-05T12:19:26","date_gmt":"2017-08-05T16:19:26","guid":{"rendered":"https:\/\/themespress.ca\/?p=5197"},"modified":"2022-10-01T15:07:16","modified_gmt":"2022-10-01T19:07:16","slug":"hiding-post-type-url","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/hiding-post-type-url\/","title":{"rendered":"Hiding Post Type URL In Admin Pages"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With this tutorial, we&#8217;ll show you how to hide a Post Type&#8217;s URL so if you create a custom post type that doesn&#8217;t require the single, we might want to hide the URL from our customers.<\/p>\n<p>Here&#8217;s the image.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n\n\t<div  class=\"wpb_single_image wpb_content_element vc_align_left wpb_content_element\">\n\t\t\n\t\t<figure class=\"wpb_wrapper vc_figure\">\n\t\t\t<div class=\"vc_single_image-wrapper   vc_box_border_grey\"><img decoding=\"async\" width=\"1085\" height=\"85\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher.jpg\" class=\"vc_single_image-img attachment-full\" alt=\"\" title=\"Cacher le permalien d\u2019un post type cot\u00e9 admin WordPress\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher.jpg 1085w, https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher-600x47.jpg 600w, https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher-300x24.jpg 300w, https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher-1024x80.jpg 1024w, https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher-768x60.jpg 768w, https:\/\/themespress.ca\/wp-content\/uploads\/2017\/08\/wsi-imageoptim-cacher-1320x103.jpg 1320w\" sizes=\"(max-width: 1085px) 100vw, 1085px\" \/><\/div>\n\t\t<\/figure>\n\t<\/div>\n\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>And then if you to optimize these results so your Post Types aren&#8217;t displayed in Google SERPs; a slider or hidden data for example. Make sure to check your variables in your function are (Click <a title=\"Cr\u00e9er un Post Type WordPress\" href=\"\/en\/creating-a-custom-post-type\/\">here<\/a> to learn how to create a custom post type):<\/p>\n<p>public =&gt; false,<br \/>\nhas_archive =&gt; false<br \/>\npublicly_queryable =&gt; false<\/p>\n<p>In our WordPress function, which we will implement in our functions.php or plugin core file, we will add a condition to hide the link if the Post Type is in the Admin head such as:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-3307331\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-3307331\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \n\/\/\/\/\/\/\/\/ Permalinks display no \/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\nadd_action(&#039;admin_head&#039;, &#039;votretheme_permalink_none&#039;);\nfunction votretheme_permalink_none() {    \n\tglobal $post_type;    \n\tif ($post_type == &#039;CPT_NAME_HERE&#039; ) {        \n\t    echo &#039;&lt;style&gt;#edit-slug-box, #message a {display:none;}&lt;\/style&gt;&#039;;\n    } \n\telseif ($post_type == &#039;CPT_NAME_HERE&#039; ) { \n\t    echo &#039;&lt;style&gt;#edit-slug-box, #message a, #post-status-info, #postdivrich {display:none;}&lt;\/style&gt;&#039;;\n\t} \n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>You can also add a condition where all your Archive and Single post types are redirected to your homepage. That way Google won&#8217;t index those. If you don&#8217;t want to use this function, you can also do so via the highly recommended Yoast SEO plugin.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-4684664\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-4684664\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function votretheme_postype_redirect() {\n    global $wp_query;\n \n    \/\/ redirect from &#039;slideshow&#039; CPT to home page\n    if ( is_archive(&#039;CPT_NAME_HERE&#039;) || is_singular(&#039;CPT_NAME_HERE&#039;) ) :\n        $url   = get_bloginfo(&#039;url&#039;);\n \n        wp_redirect( esc_url_raw( $url ), 301 );\n        exit();\n    endif;\n}\n \nadd_action ( &#039;template_redirect&#039;, votretheme_postype_redirect&#039;, 1);<\/pre><\/div><\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial, we'll show you how to hide a Post Type's URL so if you create a custom post type that doesn't require the single, we might want to<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/hiding-post-type-url\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":5203,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[318,326],"class_list":["post-5197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-functions","tag-users"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=5197"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5197\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/5203"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=5197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=5197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=5197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}