Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

Sposób na usunięcie typu wpisów z adresu URL

Sposób na usunięcie typu wpisu z adresu URL

Nie wiesz jak usunąć skróconą nazwę z adresu URL nowego typu wpisów? W tym wpisie znajdziesz wersję video oraz tekstową jak usunąć slug z CPT

Po co usuwać skróconą nazwę z adresu URL?

Są dwie możliwości:

  • możesz pozostawić skróconą nazwę w adresie URL, jeżeli nazwa typu wpisu wspomoże i doprecyzuje treść którą umieszczasz na stronie internetowej.
    W poniższym przykładzie nie ma sensu usuwać z adresu URL „Aparatura”, bo ta fraza jest połączona z wszystkimi podstronami i nie ma duplikatu treści. Ja dla przykładu przedrostek „filmy” umieściłem tylko i wyłącznie, by docierać do osób dla których filmik jest najbardziej wartościową treścią.
Kiedy zostawić skróconą nazwę w WordPress?
  • Pozostawianie skróconej nazwy w adresie URL nie ma jednak sensu, jeżeli nie zamierzasz jej w żaden sposób wykorzystywać i nie ma znaczenia dla SEO.

Dlaczego nie mogę użyć opcji With Front we wtyczce Custom Post Type UI?

Bo służy ona do czegoś innego – wytłumaczyłem to w filmie, w którym tłumaczę wszystkie ustawienia we wtyczce Custom Post Type UI tutaj.

Sprawdzony sposób na usunięcie skróconej nazwy z adresu URL

/**
     * 
     * Odc. 3. Jak usunąć z adresu URL skróconą nazwę nowego typu wpisu?
     * 
     * Źródło: https://wordpress.stackexchange.com/questions/203951/remove-slug-from-custom-post-type-post-urls
     * 
    */

    function lw_remove_slug_podcast( $post_link, $post, $leavename ) {

        if ( 'podcast' != $post->post_type || 'publish' != $post->post_status ) {
            return $post_link;
        }
    
        $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
    
        return $post_link;

    }
    add_filter( 'post_type_link', 'lw_remove_slug_podcast', 10, 3 ); 

    function lw_parse_request_podcast( $query ) {

        if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
            return;
        }
    
        if ( ! empty( $query->query['name'] ) ) {
            $query->set( 'post_type', array( 'post', 'podcast', 'page' ) );

        }

    }
    add_action( 'pre_get_posts', 'lw_parse_request_podcast' );

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *