Related Posts function not working

The ultimate answer will be in your server logs, I’m afraid. (You can also turn on debugging in wp-config – sometimes that helps too) But I did notice a few things that hopefully can help you track the issue: <?php // You should not require the $orig_post variable… global $post; // Get the tag ids … Read more

WP_User_Query and user posts

If you pass in the fields parameter to your user query you can easily get an array of ids to the pass in to your wp query : //WP User Query $author_query = new WP_User_Query( array ( ‘number’ => 3, ‘fields’ => ‘ID’ )); $author_results = $author_query->results; //WP Query $postArgs = array ( ‘author__in’=> $author_results, … Read more

get_posts() interrupt because of filter

Check that the current query is the main query using $query->is_main_query(). add_action( ‘pre_get_posts’, array($this, ‘exclude_category’) ); public function exclude_category( $query){ if( is_admin() && $query->is_main_query() && isset( $_GET[‘cta_filter’]) && ! empty( $_GET[‘cta_filter’] ) ) { $term = sanitize_text_field( $_GET[‘cta_filter’] ); $tax_query = $query->get(‘tax_query’) ?: array(); $tax_query[] = array( ‘taxonomy’ => ‘cta_tax’, ‘field’ => ‘slug’, ‘terms’ => … Read more

WordPress query reverse order

Since you are using ‘post__in’ in the ‘orderby’ parameter, the ‘order’ parameter will have no effect, however, you can simply reverse the array you are passing to ‘post__in’: $args = array( ‘post_type’ => ‘etlap’, ‘posts_per_page’ => 5, ‘post__in’ => array_reverse($ids), ‘post_status’ => ‘any’, ‘orderby’ => ‘post__in’ );

How to get image from url from the database?

I’d highly recommend to escape all values before output, e.g. echo esc_html( $retrieved_data->NAME ). The same for the image: <img src=”https://wordpress.stackexchange.com/questions/292680/<?php echo esc_url( $retrieved_data->icon ); ?>” /> You can read more about Securing Output in the developer handbook.

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