Site logo

Archived topic

How to use custom loop

7 replies · Started by Tesco on February 26, 2022

Viewing posts 1–8 of 8

I want to use a custom loop (just like bellow). How can I do that without alter core files?

<ul class="content">
<?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();?>

<li class="myclass" title="<?php the_title_attribute(); ?>" id="post-<?php the_ID(); ?>">
<?php
$time = get_post_meta($post->ID, 'time', true);
$views = get_post_meta($post->ID, 'views', true);?>
<?php if(!empty($time)) : ?>
<?php echo $time; ?><?php if (current_user_can ('manage_options')){ echo ' - ' . $views ; } ?>
<?php else : ?>
<span class="time"><span class="icon-calendar-alt"></span> <?php the_date('Y-m-d'); ?><?php if (current_user_can ('manage_options')){ echo ' - ' . $views ; } ?></span>
<?php endif ?>

" rel="bookmark">

<h2 class="title"><?php the_title(); ?></h2>

<?php endwhile; ?>

But how can I add the custom loop?

Do I have to copy and alter any theme template?

Hi there,

where are you wanting to display the Custom Loop ? Is it on its own page, within the content of your post or before/after the post ?

Hi David,

I want to display the Custom Loop on its own page OR within the content (using elements). The main issue here is how can I do it and consider that I must have page navigation also.

Which is the best way to do it?

Thanks

Thanks, David!

I will investigate this option further.

You're welcome

This archived topic is closed to new replies.