How to make multiple Column in archive Page?

You can use WP_Query to create multiple loops in your archive template file. Each loop could pull posts from a different category if you want, just set the category parameters. In the codex there’s a whole section on multiple loops too.

Showing current subcategory

I have a suspicion that you’ve fallen into a misunderstanding a lot of new users fall into, but rarely realise. I suspect you have done this: This is bad, and suggests a lack of understanding about how categories work. It will also cause issues in your code when your assumptions don’t match the reality of … Read more

Random post, page inside post loop problem

Assuming you have an original query that is wrapping the code you pasted, it looks like <?php wp_reset_query(); ?> is your issue, but I’m pretty sure you should be able to replace it with <?php wp_reset_postdata() ?> to get back to your original $post variable within the main query.

post loop causes wp_users and wp_usermeta DB queries for each users

Whilst WordPress has gotten pretty good at db caching for loops (thumbnails, post meta, terms), it does not pre-emptively cache users (authors). So if you have 5 different authors across all the posts in your loop, that’s 10 queries (1 for the user object, 1 for the user’s meta cache stash). It’s thanks to WP_Query::setup_postdata() … Read more

Custom page template

Your code will only display a list of your posts if the page that is using that template is set to be the Posts Page (in admin settings). If you want any other page to display a list of posts, then you need to write a custom query inside the template. E.g. using WP_Query: $args … Read more

Get link of inserted media file of post within loop

You can get attachment URL like this. <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/163795/<?php $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),”full’ ); echo $featured_image_url[0]; ?>”> <?php the_title(); ?> </a> <?php endwhile; endif; ?> First you will need to get the attachment ID so you will need to get it from … Read more

Getting two wp_link_pages output

Your theme is using old and deprecated function link_pages to display page-links for paginated posts. Just replace this chunk of code: <div class=”pagelink”><?php wp_link_pages(‘pagelink=Source %’); ?></div> <div class=”format_text”> <?php the_content(‘<p>Read the rest of this entry &raquo;</p>’); ?> <?php link_pages(‘<p><strong>Pages:</strong> ‘, ‘</p>’, ‘number’); ?> </div> with this: <div class=”format_text”> <?php the_content(‘<p>Read the rest of this entry … Read more

WordPress Loop Through Particular Pages

Perhaps something like this $thepages = array (21,22,23); foreach ($thepages as $thepage) { $page_data = get_page( $thepage ); echo “<h3>$page_date->post_title</h3>”; echo apply_filters(‘the_content’, $page_data->post_content); // spray out other page content } See more here

next_posts_link not working in custom loop

only just use echo and get_ <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $i = 0; while ($my_query->have_posts()) : $my_query->the_post(); if($i % 2 == 0) { ?> <div class=”row”><?php } ?> <div class=”col-md-6″> <div class=”overview”> <!– Post details here –> … Read more

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