Display subpages under parent page as a list within a loop

First set your arguments(settings) $args = array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); $children = get_children( $args, $output ); then you can use something like this <?php if (!empty($children)):?> <ul class=”row”> <?php foreach($children as $dest){ $permalink = get_permalink($dest->ID); echo “<li class=”col-sm-4″><a href=”https://wordpress.stackexchange.com/questions/254608/{$permalink}”>” . $dest->post_title . “</li>”; }?> </ul> … Read more

Endless loop with wp_insert_post and wp_update_post

It sure can be written in a more efficient way (untested): $added = array(); global $wpdb; foreach($uniques as $unique){ $pagetitle = getTitle($unique); $new_post = array( ‘post_title’ => $unique, ‘post_status’ => ‘publish’, ‘post_type’ => ‘websites’ ); $pid = wp_insert_post($new_post); if ($pid) { $wpdb->query( $wpdb->prepare( “INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, ‘%s’, ‘%s’), (%d, ‘%s’, … Read more

WooCommerce Product Page Loop – Output All Product Thumbnails

The second parameter on get_the_post_thumbnail takes the size of the image you want. You’re currently passing in: apply_filters( ‘single_product_large_thumbnail_size’, ‘shop_single’ ) but change that to apply_filters( ‘single_product_small_thumbnail_size’, ‘shop_thumbnail’ ) And you’ll have the smaller image size. You can also pass in “thumbnail” or any of the custom sizes you have in that spot without the … Read more

Adding ‘current_post_item’ class to current post in the loop

You should be able to get the queried object id and use that for comparison inside your custom loop.. Before your existing loop code(what you have posted above), but obviously after the opening PHP tag.. global $wp_query; $current_id = $wp_query->get_queried_object_id(); Then somewhere inside your custom WP loops.. if( $current_id == get_the_ID() ) { // This … Read more

the_content and wp_link_pages

I guess you have: the_content(); wp_link_pages(); in your theme file. So you can instead try the following (PHP 5.4+): /** * Append the wp_link_pages to the content. */ ! is_admin() && add_filter( ‘the_content’, function( $content ) { if( in_the_loop() ) { $args = [ ‘echo’ => false ]; // <– Adjust the arguments to your … Read more

Are there any scenarios where the query_posts may be used?

query_posts() is useful in cases when there is no main query: calls to wp-admin/admin-ajax.php, wp-admin/admin-post.php or wp-login.php for example. Yes, you can achieve the same results there without query_posts() and slightly less compact code instead. But if you don’t have to care about side effects, using query_posts() is acceptable.

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