• Hello, I successfully created a custom post type (called Video), now I want these new posts to appear both togheter with all other posts (in home, search etc) and to appear in a dedicated page/listing (with pagination like other posts). I added this code to functions.php to make it possible, but I can’t filter through ?post_type=Video (I see all posts)

    Some suggestion? Thanks

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
     if (!is_admin())
     {
      $query->set( 'post_type', array( 'post', 'Video', 'attachment', 'page' ));
     }
     return $query;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    i have a problem.

    i added this function in function.php

    register_post_type('property', array(
    	    'label' => __('Real Estate'),
    	    'singular_label' => __('Property'),
    	    'public' => true,
    	    'show_ui' => true, // UI in admin panel
    	    '_builtin' => false, // It's a custom post type, not built in!
    	    '_edit_link' => 'post.php?post=%d',
    	    'capability_type' => 'page',
    	    'hierarchical' => false,
    	    'rewrite' => array("slug" => "property"), // Permalinks format
    	    'supports' => array('title','author')
    	));

    but, the problem is when i need to show the ID of the page in my theme; $post->ID it’s empty, but if I used in other post type, show the id.

    please, help me.

    Thread Starter taloweb

    (@taloweb)

    Are you trying this inside a page template, or in a post?
    Whiche file of your theme are you using?
    Inside the loop or outside?
    Why do you need to show the post ID?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type listing ….’ is closed to new replies.