Custom post type by ID in root folder

Try creating a custom rewrite rule and a custom rewrite tag. This should allow you to set up a regular expression to capture the ID and manipulate the query. Rewrite API/add rewrite rule « WordPress Codex https://goo.gl/kdEJd8 Rewrite API/add rewrite tag « WordPress Codex https://goo.gl/PVLzLh

Pre get posts for single post

First of all, $query object is passed by reference, you don’t need to return $query in pre_get_posts. Second, is_post_type_archive( ‘events’ ) will work just fine, you don’t need to use query->query_vars[]. Corrected code will look like this: function my_pre_get_posts( $query ) { if( ! is_admin() && is_main_query() && is_post_type_archive( ‘events’ ) ) { $query->set(‘orderby’, ‘meta_value_num’); … Read more

How would I use pre_get_posts to query another site for posts in my multisite network?

OK so for reference I ended up actually using switch_to_blog() and restore_current_blog(). I found no references whatever for querying multiple tables (except writing my own JOIN-statements) when followed the source code for the action pre_get_posts. A lot of advice was given to skip restore_current_blog() to save CPU-cycles but when I checked the source code for … Read more

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