Listing Fields Disappear When Using single-listing.php File

I’m using a self-created single-listing.php post_type so I can customize the layout of individual listings pages.

So far so good with that, but when I use my single-listing.php post_type template, the ratings, and custom fields and meta stuff disappears from the template.

Here’s what the individual listings pages look like when I’m NOT using my single-listing.php template:

http://cl.ly/OQk9 (note the ratings stars, contact user button etc are all there).

BUT: When I’m using my single-listing.php template here’s what I get: http://cl.ly/OQD6 (everything is gone but the Headline and description)

Any idea what’s happening here? Switching the templates back and forth results in the above differences, so I’m thinking it must be missing information on my single-listing.php page. I’m not using any theme hooks (Running this site off a Genesis child theme (Metro)) that would remove page elements or anything.

Help!

  • Weird Mike
    • Site Builder, Child of Zeus

    Is the code you posted everything that’s inside the page just as single-listing.php?

    I ask because I’m not familiar with adding code that should appear in the header.php.

    Also, check with Inspect Element (Chrome) if you are possibly getting a jquery issue as I see you’re calling a few scripts and in my experience with jquery and WP you need to watch out for conflicts without defining the proper functions to the assigned jquery.

    If you think that may be causing errors refer to this post Multiple jQuery Libraries

  • geordie_carswell
    • WPMU DEV Initiate

    I hear you on jquery conflicts, but the same javascript libraries are active on BOTH templates, so neither should work properly if that were the case.

    Here’s the entire code for the single-listing.php page, (of course, bear in mind that this child page pulls in its page elements from the parent Genesis framework:

    <?php
    /**
    * This file adds the Landing template to the Metro Theme.
    *
    * @author StudioPress
    * @package Generate
    * @subpackage Customizations
    */

    /*
    Template Name: Directory_Listing
    */

    // Add custom body class to the head

    //* Remove header, navigation, breadcrumbs, footer widgets, footer

    //switch sidebars

    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );

    genesis();

  • geordie_carswell
    • WPMU DEV Initiate

    I’m wondering if the single-listing.php template file needs a custom loop that includes Directory code in order to display the proper Directory page elements.

    That still doesn’t explain why Directory’s page elements display fine using the default post template….

    Can the developer chime in on this?

  • geordie_carswell
    • WPMU DEV Initiate

    OK, I think it may have something to do with this in the Directory code:

    //load proper theme for single listing page display
    elseif ( is_single() && 'directory_listing' == get_query_var('post_type') ) {

    //check for custom theme templates
    $listing_name = get_query_var( 'directory_listing' );
    $listing_id = (int) $wp_query->get_queried_object_id();

    if ( $listing_name ) $templates[] = "single-listing-$listing_name.php";

    if ( $listing_id ) $templates[] = "single-listing-$listing_id.php";

    $templates[] = 'single-listing.php';

    //if custom template exists load it
    if ( ! $this->directory_template = locate_template( $templates ) ) {
    //otherwise load the page template and use our own theme
    $this->directory_template = $page_template;
    $wp_query->is_single = 0;
    $wp_query->is_page = 1;

    //add_filter( 'the_title', array( &$this, 'delete_post_title' ), 11 ); //after wpautop
    add_filter( 'the_content', array( &$this, 'listing_content' ), 99 ); //after wpautop
    }

    add_filter( 'template_include', array( &$this, 'custom_directory_template' ) );

    $this->is_directory_page = true;
    }

    Devs?

  • Jack Kitterhing
    • Code Norris

    Hi there @geordie_carswell

    I hope you are well today.

    Very sorry about the delay on this one, Your using the Genesis Framework/theme?

    Can you send me through the following information please so I can check your install, settings and code. Please.

    – Mark to my attention

    – Link back to this thread

    – Include admin/network access

    – Include FTP

    – Include any relevant URLS for your site

    https://premium.wpmudev.org/contact/

    Thank you, sorry again in the delay.

    Thank you for your patience.

    Kind Regards

    Jack.

  • Arnold
    • El Macho WP

    :slight_smile: When you’re making a custom template you have to do all the work and put in everything you want to display. What you r getting is basic WordPress output. To add the directory specific things you have to add the code to display them to your template.

    For example the Custom fields that you may have add for directory in the CustomPress custom fields you ca display with

    <?php echo do_shortcode('[custom_field_block]'); ?>

    for your categories

    <?php the_dr_posted_in(); ?>

    For ratings

    <?php do_action('sr_avg_rating'); ?>

    Look at the directory/ui-front/general/single-listing.php file which is where our version of the layout is. Don’t bother with the loop part, We do that for other reasons, but you should see all the various parts that show the information.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.