Query Custom Post Type posts by Keyword/url slug
You can use the name parameter in your arguments ex: <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12, ‘name’ => ‘slug’ ); but this will only match the post with that same slug.
You can use the name parameter in your arguments ex: <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12, ‘name’ => ‘slug’ ); but this will only match the post with that same slug.
I would recommend that you use WP_Query for this one: $categories = get_categories( ‘child_of=83’ ); foreach ( $categories as $category ) { echo ‘<h3>’ . $category -> name . ‘</h3>’; echo ‘<ul>’; // create a WP_Query that retreives all posts from the specified // category which is older then 1 week $args = array( ‘cat’ … Read more
You might be able to use the query filter hook See this WPSE answer Basically, you can do something like: add_filter( ‘query’, ‘your_filter_function’ ); function your_filter_function($query_sql) { // do something to $query_sql return $query_sql; } This will get called for every query, so you’ll need to test $query_sql to make sure it’s the query you … Read more
Turns out setting explicity posts per page did if for me.
The way I see it, you have three options: Store the global search data in $_SESSION Store the global data in a transient Run the query twice, with & without the post type filter I tried storing the array in a global variable and as soon as the page refreshes with the refined search results, … Read more
Just separate query with ; as if you would be writting them in the normal sql editor. it should work. I assume your query are not reading query (returning results). they should be for CREATE, UPDATE, DELETE, ALTERsuch kind of queries not SELECT
You can set an array for the class of the div, and then inser the value of that variable as a class in the div. And create those classes in your stylesheet. In your code, the_thumbnail is inside the if($i==0), so it only prints when $i==0. Then the what’s outside the if prints just titles, … Read more
I think that I figured this out. In my functions.php file I had the below function to redirect to the checkout page when a product is added to the cart. So I captured the username variable there and then added it to the redirected URL: add_filter (‘add_to_cart_redirect’, ‘redirect_to_checkout’); function redirect_to_checkout() { global $woocommerce; $checkout_url = … Read more
REWORKED ANSWER TO ANSWER THE QUESTION In order to exclude all pages with a certain template, all you need to do is to run a meta_query to exclude all pages with the custom field _wp_page_template set to bedankt. Remember, WordPress saves the template assigned to a page as a hidden custom field called _wp_page_template With … Read more
setup_postdata takes a post object of type \WP_Post, but you’re passing it a WP_Query instead e.g. global $post; setup_postdata( $post ); Thankfully the solution is trivial, when you call the_post, it sets up the current post data for you, so removing that line is all you need to do. The second issue is that WP_Query … Read more