get_extra_permastruct example


function get_post_permalink( $post = 0, $leavename = false, $sample = false ) {
    global $wp_rewrite;

    $post = get_post( $post );

    if ( ! $post ) {
        return false;
    }

    $post_link = $wp_rewrite->get_extra_permastruct( $post->post_type );

    $slug = $post->post_name;

    $force_plain_link = wp_force_plain_post_permalink( $post );

    $post_type = get_post_type_object( $post->post_type );

    if ( $post_type->hierarchical ) {
        $slug = get_page_uri( $post );
    }

    
if ( ! is_object( $term ) ) {
        $term = new WP_Error( 'invalid_term', __( 'Empty Term.' ) );
    }

    if ( is_wp_error( $term ) ) {
        return $term;
    }

    $taxonomy = $term->taxonomy;

    $termlink = $wp_rewrite->get_extra_permastruct( $taxonomy );

    /** * Filters the permalink structure for a term before token replacement occurs. * * @since 4.9.0 * * @param string $termlink The permalink structure for the term's taxonomy. * @param WP_Term $term The term object. */
    $termlink = apply_filters( 'pre_term_link', $termlink$term );

    

function _post_format_link( $link$term$taxonomy ) {
    global $wp_rewrite;
    if ( 'post_format' !== $taxonomy ) {
        return $link;
    }
    if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
        return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug )$link );
    } else {
        $link = remove_query_arg( 'post_format', $link );
        return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug )$link );
    }
}

/** * Remove the post format prefix from the name property of the term object created by get_term(). * * @access private * @since 3.1.0 * * @param object $term * @return object */

    public function get_category_permastruct() {
        return $this->get_extra_permastruct( 'category' );
    }

    /** * Retrieves the permalink structure for tags. * * If the tag_base property has no value, then the tag structure will have * the front property value, followed by 'tag', and finally '%tag%'. If it * does, then the root property will be used, along with the tag_base * property value. * * @since 2.3.0 * * @return string|false Tag permalink structure on success, false on failure. */
Home | Imprint | This part of the site doesn't use cookies.