0
votes

I'm building a wordpress site for a client and would really like to make the menu as idiot proof as possible.

I'm using the posts functionality for the various sections of the site, with the advanced custom fields plugin to display various different kinds of content on the post page.

What I want to do is have each category listed in the menu so the user can just click News to add a news article and the link will take them to the add new post page with the news category linked and the advanced custom fields already populated.

News - Add new (add post with news category preselect) - View News (only view posts in news category)

Roster - Add new - View Roster

Jukebox - Add new - View Jukebox

Is this something that can be done? Any help would be greatly appreciated.

2

2 Answers

0
votes

This can be done with Custom Post types. A custom post type, a post type (think blog entry) that you, as the developer, can completely control. I'd recommend reading up on them at the WordPress Codex.

Essentially, you go into the functions.php file of your theme and add code similar to this:

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,
    )
  );
}

Then, you'll be able to create custom templates on your theme to be able to show these in whatever format you'd like, using your ACFs.

0
votes

you simply create two more files, one called template-roster.php and single-roster.php

This is an example of mine (template-audio.php)

<?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(); ?>