Do I need to use The Loop on pages?

According to the Theme Guide, full loops should be used, even on single templates. Full loops must be used in all templates. Just calling the_post() in a template like single.php or page.php is not enough. So yes, it’s a best practice to use full loops.

AJAX with loop filtering categories

I know this is old, this looks exactly what I need, but isn’t working ATM. I paste everything on functions.php for a reason. ONE: Category Loop for theme file: Printed it with a shortcode, because i’m using bakery I wan’t to put it in an specific place in the site. This is Working fine. <?php … Read more

How to split a loop into multiple columns

Create Columns for your query and easy display In themes is probably more useful to have something that fits well into template tags and the loop. My first answer didn’t focus on that much. Additionally I thought it’s a bit too complicated for a quick adoption. An easier approach that popped into my mind was … Read more

How to get Author ID outside the loop

The simplest and most straightforward way to get the post author ID outside the loop, if you know the post ID, is to use the WordPress core function get_post_field(). $post_author_id = get_post_field( ‘post_author’, $post_id ); If you do not yet know the post ID of the page you are on, then since WP 3.1 the … Read more

Split Content and Gallery

Open to anybody who can simplify this but here’s what I came up with that worked for me. First thing’s first – get the gallery, using get_post_gallery(), as soon as the loop starts: <?php if( have_posts() ) : ?> <?php while( have_posts() ) : the_post(); $gallery = get_post_gallery(); $content = strip_shortcode_gallery( get_the_content() ); ?> <div … Read more

Display featured products through custom loop in woocommerce on template page

Change your args to be like this: $meta_query = WC()->query->get_meta_query(); $meta_query[] = array( ‘key’ => ‘_featured’, ‘value’ => ‘yes’ ); $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘showposts’ => 6, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘meta_query’ => $meta_query ); If you go to wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php (@595) you can find how it’s done for … Read more

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