Create Cross Promoting Categories in WordPress Using ‘pre_get_posts’

I think I remember seeing this attempt somewhere… If I remember correctly, the solution was to use a custom tax query on the category.php template, but querying the taxonomy (crosspostcategory) FIRST in the “or” statement… So you’d check for the taxonomy first, and then query (tax query) the category taxonomy next in the OR statement. … Read more

How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp

I’m outlining a solution for what you asked in your last comment, because this wouldn’t been fitting for the comment format. Code: function date_time_to_timestamp_meta( $post_id ) { // meta fields are saved in DATETIME, e.g. »2013-12-09 22:32:12« // here is only the date part relevant $datetime_date = get_post_meta( $post_id, ‘_start_date’, true ); // here is … Read more

How to remove attachments from main query via pre_get_posts?

Rather than using pre_get_posts hook, you could try a better approach which will work perfectly with parse_request hook. The code – add_action( ‘parse_request’, ‘my_cpt_parse_request’, 11, 2 ); function my_cpt_parse_request( $wp ) { if( isset($wp->request) && !is_admin() ) { $requests = explode(“https://wordpress.stackexchange.com/”, $wp->request); $request_amount = count($requests); $post_name = array_shift( $requests ); // if an attachment has … Read more

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