Extend taxonomy term page with other posts

Ok I find a solution. I use posts_where filter in pre_get_posts. With this filter I can remove the term related WHERE part from the default SQL query. function custom_loops($query) { if (is_tax( ‘service_photo_location’ )){ $query->set( ‘posts_per_page’, 10); $query->set( ‘post__in’, $ids); $query->set( ‘orderby’, ‘title’); $query->set( ‘order’, ‘ASC’); add_filter( ‘posts_where’, function ( $where ) { $where = … Read more

Insert a variable in pre_get_posts

You can not use a variable inside a function which has been defined outside the function! Get the value from $_GET inside the function. function my_home_category($query) { if (isset($_GET [‘p’])) { $catvar = get_cat_ID($_GET [‘p’]); $query->set(‘cat’, $catvar); } } add_action( ‘pre_get_posts’, ‘my_home_category’ );

Why the pre_get_posts hook can cause apache stopped working?

As per this WPSE thread you are actually putting overload to the apache. That’s why it’s reacting like that. 🙂 So let’s cut the overload, use is_main_query() properly, and just add a simple conditional to your pre_get_posts hooked function: function e_exclude_posts( $query ) { if( !is_admin() && $query->is_main_query() && $query->is_tax(‘my_tax’) ) { $expired = g_get_all_the_expired_posts(); … Read more

how to get content from other site and show it?

You can use wp_remote_get or/and wp_remote_retrieve_body functions to get HTTP response Retrieve the raw response from the HTTP request using the GET method. Results include HTTP headers and content. codex here $response = wp_remote_get( $url, $args ); Retrieves the body of an already retrieved HTTP request. Codex $the_body = wp_remote_retrieve_body( wp_remote_get(‘http://example.com’) );

Custom Post Type shows pagination (w/404) or posts_per_page query, but not both

user5477769 reports in the comments of the original post, that the problem has been solved: I was following Custom Post Type UI instructions but it seems it led me astray. Creating a archive-gallery.php with a vanilla Loop, along with removing is_main_query has solved all problems, and the pages now show with 9 posts and correct … Read more

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