WordPress Prevent 404 on missing custom post

The simplest way to handle this is to create a page with slug property which will be used to display all properties, and add a rewrite rule to handle requests for property IDs.

// add property_id query var to hold ID of requested property
function wpd_query_var( $query_vars ){
    $query_vars[] = 'property_id';
    return $query_vars;
}
add_filter( 'query_vars', 'wpd_query_var' );

// add rewrite rule to handle requests for specific properties
function wpd_rewrite_rule(){
    add_rewrite_rule(
        'property/([0-9]+)/?$',
        'index.php?pagename=property&property_id=$matches[1]',
        'top'
    );
}
add_action( 'init', 'wpd_rewrite_rule' );

Visit your permalinks settings page to flush rewrite rules after adding this code to your theme’s functions.php, or in a plugin.

Then in your page-property.php template, use get_query_var( 'property_id' ); to get the ID of the requested property.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)