Forums

Custom post type listing .... (3 posts)

  1. taloweb
    Member
    Posted 1 year ago #

    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;
    }
  2. damian00
    Member
    Posted 1 year ago #

    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.

  3. taloweb
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic