• Resolved gavdo

    (@gavdo)


    Hi Newby here
    please advise me if i am posting in wrong section of forum

    QUESTION:
    Can any one tell how to get the template query below to display articles from selected categories only?

    [code moderated as per forum rules - please use the pastebin
    also, please use the 'code' button to mark any small amounts of code posted directly]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter gavdo

    (@gavdo)

    OK I have not used pastebin before. I have the embed codes but how do i get it to display here in the forum?

    Thread Starter gavdo

    (@gavdo)

    pastebin URLfor full code.

    small snippet below

    <?php $loop = new WP_Query(array( 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15)); ?>
    
    <?php if ($loop->have_posts()): ?>
    
    <?php while ($loop->have_posts()): $loop->the_post(); $posts_counter++; ?><?php
    global $more; $more = 0;
    ?>

    try:

    <?php $loop = new WP_Query(array( 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15, 'category__in' => array(3,9,23,125)); ?>

    http://codex.ww.wp.xz.cn/Class_Reference/WP_Query#Category_Parameters

    Thread Starter gavdo

    (@gavdo)

    Thanks for that. I have tried it but to no avail.
    If you have anymore suggestions I would love to try them.
    Got to go for a while but will check back in 3hrs or so.

    what is happening if you add the changes?
    – nothing different?
    – all posts?
    – no posts?

    are you sure that the page you are looking at is done with the template that you edited?

    http://codex.ww.wp.xz.cn/Template_Hierarchy

    link to your site, to the page where you want to restrict the posts?

    Thread Starter gavdo

    (@gavdo)

    Hi alchymyth
    When i implimented the change I get a syntex error blank page display Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in /home/phat/public_html/wp-content/themes/theme1122/page_home.php on line 30. 30 is the modified line
    It is definately the right template as i have been changing various elements on it.
    The site is http://www.cre8ivdesign.co.uk and the template operates directly on the front page controling the image grid.

    Thread Starter gavdo

    (@gavdo)

    Problem sorted. The original coding was done using $ commands so i removed all of these and substituted them for the standard wordpress coding <?php query_posts('cat=4&showposts=15&paged='.$paged); ?><ul class="latest-posts"><?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    thank you for your assistance alachymyth

    well done 😉

    just for your information:
    the parse error was my mistake – i forgot to close a bracket in my suggested code changes 🙁
    (there should have been three closing brackets)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Codex query’ is closed to new replies.