Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 添加自定义管理菜单选项_Wordpress_Admin - Fatal编程技术网

Wordpress 添加自定义管理菜单选项

Wordpress 添加自定义管理菜单选项,wordpress,admin,Wordpress,Admin,我正在为一个客户建立一个wordpress网站,我真的很想让菜单尽可能的防白痴 我正在为网站的各个部分使用posts功能,并使用高级自定义字段插件在post页面上显示各种不同的内容 我想做的是在菜单中列出每个类别,这样用户只需单击“新闻”即可添加新闻文章,链接会将他们带到“添加新文章”页面,其中链接了新闻类别,并且已经填充了高级自定义字段 新闻 -添加新内容(添加带有新闻类别预选的帖子) -查看新闻(仅查看新闻类别中的帖子) 名册 -新增 -查看花名册 自动点唱机 -新增 -查看自动存储塔 这是

我正在为一个客户建立一个wordpress网站,我真的很想让菜单尽可能的防白痴

我正在为网站的各个部分使用posts功能,并使用高级自定义字段插件在post页面上显示各种不同的内容

我想做的是在菜单中列出每个类别,这样用户只需单击“新闻”即可添加新闻文章,链接会将他们带到“添加新文章”页面,其中链接了新闻类别,并且已经填充了高级自定义字段

新闻 -添加新内容(添加带有新闻类别预选的帖子) -查看新闻(仅查看新闻类别中的帖子)

名册 -新增 -查看花名册

自动点唱机 -新增 -查看自动存储塔


这是可以做到的吗?任何帮助都将不胜感激。

这可以通过自定义帖子类型完成。一个自定义的帖子类型,一个你作为开发者可以完全控制的帖子类型(比如博客条目)。我建议你在网上读一下

本质上,您进入主题的functions.php文件并添加类似于以下内容的代码:

add_action( 'init', 'create_post_type' );

function create_post_type() {
  register_post_type( 'roster',
    array(
      'labels' => array(
        'name' => __( 'Roster' ),
        'singular_name' => __( 'Roster' )
      ),
    'public' => true,
    'has_archive' => true,
    )
  );
}

然后,您就可以在主题上创建自定义模板,以便能够使用ACF以任何格式显示这些模板。

您只需再创建两个文件,一个名为template-lotster.php和single-lotster.php

这是我的一个例子(template audio.php)



谢谢!应该能够让这一切顺利进行。但我如何查询这些自定义帖子类型?我无法确定将循环/查询放在哪个模板中?如果您查看我提供的Codex的链接,页面的下一步将解释如何查询自定义帖子类型。
<?php
/*
Template Name: Audio
*/
?>

<?php get_header(); ?>

    <div id ="content" class="audio grid_12">

            <h1 class="pagetitle"> <?php the_title(); ?> </h1>

             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                                                           
                    <?php the_content(); ?> 
            <?php endwhile; endif; ?>    

            <div class="clear">
            </div><!-- .clear-->                

            <ul class="album">
            <?php  
                    global $post;

                    $args = array(
                                    'order' => 'DESC',
                                    'post_type' => 'audio',
                                    'posts_per_page' => -1 );

                    $loop = new WP_Query( $args );

                    while ( $loop->have_posts() ) : $loop->the_post();

                    $album_title = $post->post_title;
                    $album_thumb = get_the_post_thumbnail($post->ID, 'square1', array('title' => ''))                               
            ?>                

                    <li>
                            <div class="album_item mosaic-block bar">
                                    <a href="<?php the_permalink() ?>">                                        
                                            <div class="details mosaic-overlay aud-size">
                                                    <?php echo $album_title; ?>
                                            </div>

                                            <div class="album_artwork mosaic-backdrop">                                                
                                                    <?php echo $album_thumb; ?>     
                                            </div>
                                    </a>
                            </div><!-- .album_item-->
                    </li>
    <?php       
                    endwhile;

                    // Always include a reset at the end of a loop to prevent conflicts with other possible loops                 
                    wp_reset_query();
            ?>
            </ul>
    </div><!-- #content-->

    <div class="clear">
    </div><!-- .clear-->

<?php get_footer(); ?>