loop – Best practice to display a list/archive of Custom Posts in a Page Template
I often need to have a Page, whose content is editable by an editor user in admin, displaying a list of Custom Posts.
So I create a Page in the admin and create a Page Template (ex : page-my_cpt.php) and run a custom WP_Query to fetch the posts inside this template. It works, but I keep reading that it is not a best practice, that running a custom WP_Query is slow (why is that?), and that it is better to use the pre_get_posts action if I need to modify the main query.
But this can only work when using the custom post archive template, and thus, the editor user cannot add a content as he can do it in a Page.
I am confused… What do you think ?
Leave an answer