how to get custom attachment url?
how to get custom attachment url?
how to get custom attachment url?
maybe you have to use this $categories=get_categories( array( ‘parent’ => $cat->cat_ID ) ); Then, in a loop, display this array because you can’t do it with an echo foreach ($categories as $c) { var_dump($c); // what you really want instead of var_dump is something to // to create markup– list items maybe, For example… echo … Read more
Yes, absolutely, it is possible. And here’s an example: Use an action and pass the post’s position in the loop to the action’s callback/function, and let the callback run the conditional and display the image if applicable. $position = 1; // start at 1 while ( have_posts() ) : the_post(); the_title( ‘<h3>’, ‘</h3>’ ); // … Read more
Order Element By Custom Field in WordPress
Wp_Query Post per page not working?
Woocommerce featured products query no longer working
I was able to find a function that worked found here. First, I added the below code to my functions.php, which excludes the parent categories I do not want: function custom_get_the_category_list() { $categories = get_the_category(); $exclude1 = get_cat_ID( ‘Parent1’ ); $exclude2 = get_cat_ID( ‘Parent2’ ); $categories_list=””; foreach ( $categories as $category ) { if ( … Read more
I’m sure there are more sophisticated ways to debug the queries, but I’m not aware of them. So usually when I need to debug WP queries I use either Query Monitor or Debug Bar (with Slow Actions addon) plugin, which can be found on the wordpress.org plugin repository. These plugins help you trace which functions … Read more
You have to use “orderby” => “meta_value_num” and set a “meta_query” at the same time. Then choose the “meta_key” you want to order by. Try: $query = new WP_Query( array( ‘post_type’ => ‘some_cpt’, ‘posts_per_page’ => – 1, ‘meta_query’ => array( array( ‘key’ => ‘active’, ‘value’ => ‘1’, ‘compare’ => ‘=’, ) ), ‘meta_key’ => ‘ranking’, … Read more
You’ll have a much easier time if you use the main query, and add your extra filters with pre_get_posts. So first of all, just use search.php as your template, and use the main query. So no new WP_Query(), and use the have_posts() and the_post() functions, not the methods. So your template (simplified) would be like … Read more