CustomPress single-xxx.php example

The Events plugin isn't what I need for just "online" events so I decided to go with making my own custom post types. I have an events type setup with a few custom fields to start with and a few taxonomies. The plugin has created the single-events.php page but it's just a copy of the single.php file (correct, right?)
Not much code in it and I'm not a php programmer and I can't really tell where to insert the embed codes for the fields and taxonomies. Can someone give me an example or show me where/how to do this? Thanks.

  • TerryG

    Using the Abundance theme from by Kriesi. Here's the whole code for the single-events.php file:

    <?php
    global $avia_config;
    
    	avia_get_template();
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */
    	 get_header();
    
    	?>
    
    		<!-- ####### MAIN CONTAINER ####### -->
    		<div class='container_wrap <?php echo $avia_config['layout']; ?>' id='main'>
    
    			<div class='container'>
    
    				<?php avia_title(); ?>
    				<div class='template-blog template-single-blog content'>
    
    				<?php
    				/* Run the loop to output the posts.
    				* If you want to overload this in a child theme then include a file
    				* called loop-index.php and that will be used instead.
    				*
    				*/
    
    					get_template_part( 'includes/loop', 'index' );
    
    					//show related posts based on tags if there are any
    					get_template_part( 'includes/related-posts');
    
    					//wordpress function that loads the comments template "comments.php"
    					comments_template( '/includes/comments.php'); 
    
    				?>
    
    				<!--end content-->
    				</div>
    
    				<?php
    				$avia_config['currently_viewing'] = "blog";
    				//get the sidebar
    				get_sidebar();
    
    				?>
    
    			</div><!--end container-->
    
    	</div>
    	<!-- ####### END MAIN CONTAINER ####### -->
    
    <?php get_footer(); ?>
  • Kimberly

    As per the instruction on the usage Simply copy the embed code and place it inside your WordPress loop to display the new taxonomy with your theme.

    So your loop is, as per the Codex:

    The loop starts here:

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

    and ends here:

    <?php endwhile; else: ?>

    Have you compared the new file to the single.php file? It should be a copy, however it will depend on how your theme is set up. :slight_smile:

    Best,

    Kimberly

  • TerryG

    Clear as mud. The code for my entire single-events.php is displayed above. So the embed code doesn't go in the new single-events.php template page? Looking at the Codex it states that the Loop should be in the index.php file of the theme. I don't see any code that looks like anything like that in any index.php file I have.

    If I ever find the Loop and insert the code, wouldn't every post display that information?

    I'm still confused ...

  • Kimberly

    Terry, I can understand your frustration and I am very sorry.

    If I had access to the theme i would install and test this myself. However you are using a premium Themeforest theme so I cannot.

    When CustomPress creates a template for a Custom Post it uses the single post type for it's template. Most post templates use the standardthe_post(); and <?php endwhile; else: ?> in the post template. However you come across some that act a bit differently. Twenty Eleven is one of these, it uses additional templates to create portions of the post template. That is what your theme seems to be doing as well.

    http://codex.wordpress.org/Function_Reference/get_template_part

    To create a custom post type in a theme like yours you will need to look at the portion you want to change. Since we know that we need to put your embed codes in "the loop" then we see what portion of your theme is calling it. so we read:

    /* Run the loop to output the posts.
    				* If you want to overload this in a child theme then include a file
    				* called loop-index.php and that will be used instead.
    				*
    				*/
    
    					get_template_part( 'includes/loop', 'index' );

    This is the portion your template is calling for the loop. This is where your embed code will go, in this template. I wish I could be more specific, but I don't have the file. Very Sorry.

    When you created your Custom Fields you had the option of choosing what post type would display them. If you selected your Events post type only then the fields will show in the events post type only.

    Hope that is a bit clearer. The use of advanced plugins like this one can be frustrating and tedious.

    Best

    Kimberly

  • aecnu

    Greetings TerryG,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.