get_post_type_archive_link example

array(
                        'id'    => 'view',
                        'title' => $post_type_object->labels->view_item,
                        'href'  => get_permalink( $post->ID ),
                    )
                );
            }
        } elseif ( 'edit' === $current_screen->base
            && ( $post_type_object )
            && ( $post_type_object->public )
            && ( $post_type_object->show_in_admin_bar )
            && ( get_post_type_archive_link( $post_type_object->name ) )
            && ! ( 'post' === $post_type_object->name && 'posts' === get_option( 'show_on_front' ) ) ) {
            $wp_admin_bar->add_node(
                array(
                    'id'    => 'archive',
                    'title' => $post_type_object->labels->view_items,
                    'href'  => get_post_type_archive_link( $current_screen->post_type ),
                )
            );
        } elseif ( 'term' === $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
            $tax = get_taxonomy( $tag->taxonomy );
            if ( is_term_publicly_viewable( $tag ) ) {
                

function get_post_type_archive_feed_link( $post_type$feed = '' ) {
    $default_feed = get_default_feed();
    if ( empty( $feed ) ) {
        $feed = $default_feed;
    }

    $link = get_post_type_archive_link( $post_type );
    if ( ! $link ) {
        return false;
    }

    $post_type_obj = get_post_type_object( $post_type );
    if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
        $link  = trailingslashit( $link );
        $link .= 'feed/';
        if ( $feed != $default_feed ) {
            $link .= "$feed/";
        }
    }
if ( ! isset( $post->type_label ) ) {
            $post->type_label = $this->get_type_label( $post );
        }

        // Ensure nav menu item URL is set according to linked object.         if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) {
            $post->url = get_permalink( $post->object_id );
        } elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) {
            $post->url = get_term_link( (int) $post->object_id, $post->object );
        } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
            $post->url = get_post_type_archive_link( $post->object );
        }
        if ( is_wp_error( $post->url ) ) {
            $post->url = '';
        }

        /** This filter is documented in wp-includes/nav-menu.php */
        $post->attr_title = apply_filters( 'nav_menu_attr_title', $post->attr_title );

        /** This filter is documented in wp-includes/nav-menu.php */
        $post->description = apply_filters( 'nav_menu_description', wp_trim_words( $post->description, 200 ) );

        
$suppress_page_ids[] = $privacy_policy_page->ID;
                    }
                }
            } elseif ( 'post' !== $object_name && 0 === $page && $post_type->has_archive ) {
                // Add a post type archive link.                 $items[] = array(
                    'id'         => $object_name . '-archive',
                    'title'      => $post_type->labels->archives,
                    'type'       => 'post_type_archive',
                    'type_label' => __( 'Post Type Archive' ),
                    'object'     => $object_name,
                    'url'        => get_post_type_archive_link( $object_name ),
                );
            }

            // Prepend posts with nav_menus_created_posts on first page.             $posts = array();
            if ( 0 === $page && $this->manager->get_setting( 'nav_menus_created_posts' ) ) {
                foreach ( $this->manager->get_setting( 'nav_menus_created_posts' )->value() as $post_id ) {
                    $auto_draft_post = get_post( $post_id );
                    if ( $post_type->name === $auto_draft_post->post_type ) {
                        $posts[] = $auto_draft_post;
                    }
                }
$posts_page = '';

            // For taxonomies that belong only to custom post types, point to a valid archive.             $taxonomy_object = get_taxonomy( $parsed_args['taxonomy'] );
            if ( ! in_array( 'post', $taxonomy_object->object_type, true ) && ! in_array( 'page', $taxonomy_object->object_type, true ) ) {
                foreach ( $taxonomy_object->object_type as $object_type ) {
                    $_object_type = get_post_type_object( $object_type );

                    // Grab the first one.                     if ( ! empty( $_object_type->has_archive ) ) {
                        $posts_page = get_post_type_archive_link( $object_type );
                        break;
                    }
                }
            }

            // Fallback for the 'All' link is the posts page.             if ( ! $posts_page ) {
                if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
                    $posts_page = get_permalink( get_option( 'page_for_posts' ) );
                } else {
                    $posts_page = home_url( '/' );
                }
if ( $object ) {
                    $menu_item->title      = ( '' === $menu_item->post_title ) ? $object->labels->archives : $menu_item->post_title;
                    $post_type_description = $object->description;
                } else {
                    $post_type_description = '';
                    $menu_item->_invalid   = true;
                }

                $menu_item->type_label = __( 'Post Type Archive' );
                $post_content          = wp_trim_words( $menu_item->post_content, 200 );
                $post_type_description = ( '' === $post_content ) ? $post_type_description : $post_content;
                $menu_item->url        = get_post_type_archive_link( $menu_item->object );

            } elseif ( 'taxonomy' === $menu_item->type ) {
                $object = get_taxonomy( $menu_item->object );
                if ( $object ) {
                    $menu_item->type_label = $object->labels->singular_name;
                } else {
                    $menu_item->type_label = $menu_item->object;
                    $menu_item->_invalid   = true;
                }

                $original_object = get_term( (int) $menu_item->object_id, $menu_item->object );

                
array_unshift(
                        $posts,
                        (object) array(
                            'ID'           => 0,
                            'object_id'    => $_nav_menu_placeholder,
                            'object'       => $post_type_name,
                            'post_content' => '',
                            'post_excerpt' => '',
                            'post_title'   => $post_type->labels->archives,
                            'post_type'    => 'nav_menu_item',
                            'type'         => 'post_type_archive',
                            'url'          => get_post_type_archive_link( $post_type_name ),
                        )
                    );
                }

                /** * Filters the posts displayed in the 'View All' tab of the current * post type's menu items meta box. * * The dynamic portion of the hook name, `$post_type_name`, refers * to the slug of the current post type. * * Possible hook names include: * * - `nav_menu_items_post` * - `nav_menu_items_page` * * @since 3.2.0 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. * * @see WP_Query::query() * * @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but * can also contain "fake" post objects to represent other menu items. * @param array $args An array of `WP_Query` arguments. * @param WP_Post_Type $post_type The current post type object for this menu item meta box. */
Home | Imprint | This part of the site doesn't use cookies.