Show post like this image in my newssite [closed]

I’m not sure what you’re asking for. If you need a simple query for a category. try generatewp.com for the fastest solution. Here’s how to code it yourself. https://codex.wordpress.org/Class_Reference/WP_Query you’ll want to use the Category_Parameters

Can’t get LIKE to work with wp_query [closed]

When you set up the meta_query value like: ‘value’ => “‘” . $city . “‘”, it gets translated to LIKE ‘%\’ondon\’%’ in the final SQL query, which matches things like L’ondon’ or L’ondon’er but not London. But you actually want it to be like: LIKE ‘%ondon%’ – so you should do: ‘value’ => $city, EDIT … Read more

How can I echo out the user id in user meta?

If you want to display the info on the current user logged in you can use get_currentuserinfo. [Codex] Example from Codex <?php global $current_user; get_currentuserinfo(); echo ‘Username: ‘ . $current_user->user_login . “\n”; echo ‘User email: ‘ . $current_user->user_email . “\n”; echo ‘User first name: ‘ . $current_user->user_firstname . “\n”; echo ‘User last name: ‘ . … Read more

Query page: preserve page formating

You’re comparing apples to oranges here. Both queries do the exact same thing, but are presented through different code. Your query: <?php $my_postid = 663;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; ?> Merely pulls some content out of … Read more

Pagination on custom post type not working

Fixed it by changing the page’s name (more so the page’s URL) so that it did not match the post type name, which causes rewrite problems. I also learned that previous_posts_link(); and next_posts_link(); as well as wp_paginate() rely on the query variable being named “$wp_query”, so “$my_query” doesn’t work. Here’s my fixed code: if ( … Read more

Incorrect posts displayed on category page

First of all, never ever make use of query_posts. It is not just slow and reruns queries, but it breaks pagination, page functionalities and the globals like $post on which some theme functionalities and plugins rely. If you really need to run custom queries (which is totally unnecessary in this case), make use of WP_Query … Read more

query_vars category_name only display one catgory out of multiple categories

Inside get_posts() of WP_Query class, you will see this code block. /* * Ensure that ‘taxonomy’, ‘term’, ‘term_id’, ‘cat’, and * ‘category_name’ vars are set for backward compatibility. */ if ( ! empty( $this->tax_query->queried_terms ) ) { /* * Set ‘taxonomy’, ‘term’, and ‘term_id’ to the * first taxonomy other than ‘post_tag’ or ‘category’. */ … Read more

Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]

You’ll find details here: https://gist.github.com/lukecav/05afef12feaf980c121da9afb9291ad5 OR Another approach is https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query . Use if….else and store order data in Arr[product_id] = OrderArr Kindly accept my answer if it is of any help.