Style Post Differently In Query

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

WP_Query Authors OR Categories

Custom feed slug To create a custom feed slug, e.g. example.tld/billyfeed/ we can use the add_feed() but we have to flush the rewrite rules to activate it. We can do that e.g. by visiting the Permalinks settings page in the backend. To generate the feed we can use e.g. do_feed_rss2() or do_feed_atom(). Here’s an example: … Read more

Get posts by name and taxonomy term

Note that if you have the post slug, you don’t need the additional taxonomy query to find that post, so it makes sense to drop the expensive taxonomy query in core in that case. Otherwise you could try instead the post_name__in parameter: [ ‘post_name__in’ => [ ‘<postslug>’ ], ‘tax_query’ => [ [ ‘taxonomy’ => ‘<taxonomy>’, … Read more

WP Query with custom Shortcode

There are few issue with your code When using WP_Query in conjuction with the_post() or using get_posts() in conjuction with setup_postdata( $post ), you need to reset the $post global with wp_reset_postdata(), not wp_reset_query(). wp_reset_query() is used in conjuction with query_posts() which you should never ever use You would want to reset posdata between your … Read more

Create WP_Query to search for posts by their categories or their parent/child categories

Use get_categories first to get all the post categories to use in the form, then loop through them to display a multicheck input… function hierarchical_category_inputs ($cat, $indent) { $cats = get_categories(‘hide_empty=false&orderby=name&order=ASC&parent=”.$cat); $indent++; if ($cats) { foreach ($cats as $cat) { echo “<input type=”checkbox’ name=”cat-“.$cat->term_id.”””; echo ” style=”margin-left: “.($indent*10).”px;”> “.$cat->name.”<br>”; hierarchical_category_inputs($cat->term_id, $indent); } } } echo … Read more

unable to retrive parent page information

As defined by the WordPress codex use this to get the parent get_post_ancestors( $post ) , The direct parent is returned as the first value in the array. Edit: get_post_ancestors( get_queried_object_id() ) can also work WordPress Codex

Query Strings and Woocommerce

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

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