Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter wpnovice241

    (@wpnovice241)

    Thank you very much…

    Always an active moderator and very very knowledgeable, I salute you!

    Thread Starter wpnovice241

    (@wpnovice241)

    You are a legend and I sincerely thank you for this.

    Now that I have seen it in action, I understand it and would be able to write it again, I am a very weird learner (as you can probably tell) and need to see things, then dissect them to understand how they work!!!

    Thank you again

    Thread Starter wpnovice241

    (@wpnovice241)

    Thanks, I am having trouble inserting it into my code and making it work.

    Sorry about this, I am fairly new to PHP in general and am a visual learner, it looks right but strikes up a syntax error of unexpected T_ENDIF error!

    My code again looks like this :

    <div class="column half">
    
    <?php query_posts('posts_per_page=1&category_name=movies'); if ( have_posts() ) : while ( have_posts() ) : the_post();?>
    
    		<div class="latest">
        		<h3>Latest Post: <a href="<?php the_permalink();?>"><?php the_title(); ?></a></h3>
        		<p><?php the_excerpt() ; ?></p>
        		<a href="<?php the_permalink();?>">Read Full Article..</a>
    		</div>
    
    <?php endwhile; endif; wp_reset_query(); ?>
    
    	</div>  <!-- Column Half -->

    Thank you and sorry for not being better haha!!

    Thread Starter wpnovice241

    (@wpnovice241)

    yeah i apologise for that, i re read it and it was disgusting. haha!

    For instance, if i have 2 categories and 2 pages (movies and games). I want to display the posts I make in the movies category on the movies and games posts on the games page.

    At the minute I have a template part which looks like this:

    <?php
        query_posts('posts_per_page=1&category_name=movies');
        if ( have_posts() ) : while ( have_posts() ) : the_post();
    ?>
    
    <div class="latest">
        <h3>Latest Post: <a>"><?php the_title(); ?></a></h3>
        <p><?php the_excerpt() ; ?></p>
        <a>">Read Full Article..</a>
    </div>
    
    <?php endwhile; endif; wp_reset_query(); ?>

    [Please post code or markup snippets between backticks or use the code button. As it stands, your posted code has been permanently damaged/corrupted by the forum’s parser.]

    What I want to know is—-

    Is there a way that I can add to the code above to tell wordpress that if i am on the movies page show the latest post from the movies category and if I am on the games page show the latest post from the games category.

    I dont want to have to write multiple templates or template parts as that seems to be more files on my server!

    I really do hope this helps to clear up the matter and I have explained it in a better way!

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