Let me make use of a custom publish type archive like a site's top of the page, to ensure that

 http://the_site.com/

is really a custom publish type archive displayed based on my archive-{post-type}.php file.

Ideally I must affect the query using is_front_page() during my functions.php file. I attempted the next, having a page known as "Home" as my top of the page:

 add_filter('pre_get_posts', 'my_get_posts');
 function my_get_posts($query){
     global $wp_the_query;
     if(is_front_page()&&$wp_the_query===$query){
        $query->set('post_type','album');
        $query->set('posts_per_page',-1);
     }
     return $query;
 }

however the top of the page is coming back this content of "Home" and appears to become disregarding the custom query.

What shall we be held doing wrong? It is possible to better way, generally, of carrying out this?

Note: Used to do publish this in WordPress Answers but that community is pretty small.

To be able to have that query to operate, you are going to need to include that code to some page template, produce a page, set your template because the template for that page you simply produced, after which set that page because the webpage in Configurations => Reading through within the admin area.

Incidentally, the is_front_page() function only returns true if you are on the page which has been set because the webpage in the admin menu.

Another option is to change index.php, but when you probably did that, is_front_page() would always return false. For the reason that situation, you would use is_home() rather.

Hopefully helps.

Isaac, you're correct, I did not completely read your question and that i made the assumption that you simply were searching to get this done the "easy" way.

Anyway, I place your code on my small test site and, indeed, it did not work. I checked out my SQL log also it works out that the code produces this within the query wp_posts.post_status = 'private'.

So, I attempted adding the road $query->set('post_status', 'public'); for your function, also it labored all right.

To sum up, do this:

add_filter('pre_get_posts', 'my_get_posts');
function my_get_posts($query){
    global $wp_the_query;
    if(is_front_page()&&$wp_the_query===$query){
        $query->set('post_type','album');
        $query->set('posts_per_page',-1);
        $query->set('post_status', 'public');
    }
    return $query;
}