WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Listing Page (2 posts)

  1. betoranaldi
    Member
    Posted 3 years ago #

    I am looking to customize the listing page of my custom post times.

    Right now it seems to be using the default listing page.

    Is there anyway I can override this and create a custom listing page, just for this custom post type?

  2. faboulaws
    Member
    Posted 3 years ago #

    For you listing you need to create a template file in you there.For example for the post type "properties" your template file name could be properties.php.Now to list the properties post type you need to adda template redirect action like bellow.

    add_action("template_redirect", 'my_template_redirect');
    
    	// Template selection
    	function my_template_redirect()
    	{
    	    global $wp;
    	    global $wp_query;
    	    if ($wp->query_vars["post_type"] == "properties")
    	    {
    	        // Let's look for the properties.php template file in the current theme
    	        if (have_posts())
    	        {
    	            include(TEMPLATEPATH . '/properties.php');
    	            die();
    	        }
    	        else
    	        {
    	            $wp_query->is_404 = true;
    	        }
    	    }
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic