0
votes

I have three Posts in WordPress that each have the category Event.

I'm assuming that i use a WordPress codex to call those Posts to display when i want to.

What is happening is these Posts are all being displayed on index.php. I want to be able to use the WordPress codex and get the Posts for a certain category and display them. For example, display the posts in a pop up div.

How do i get Posts not to be displayed on the front page? How do i get Posts of a specific category to display?

Or am i going about this the wrong way? I assume that Posts can be fetched from the database and be put in a popup div.

Here is my main inner html of my index.php

<div id="main">
        <div id="nav">
        <?php 

            if(!isset($_GET['page_id'])) {

                wp_nav_menu( array( 'theme_location' => 'main-menu'));
            }
        ?>
        </div>

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
            the_content();
            endwhile; else: ?>
            <p>Sorry, no posts matched your criteria.</p>
            <?php endif; ?>
    </div>

I want it to fetch the current Page content and not the Posts.

1

1 Answers

0
votes
<?php 
if(!is_home() || !is_front_page) { // dont display on home page

if ( have_posts() ) : while ( have_posts() ) : the_post();
            the_content();
            endwhile; else: ?>
            <p>Sorry, no posts matched your criteria.</p>
            <?php endif;
}
 ?>

look here for more conditional tags template tags

and to get posts from a particular category you can pass args in wp_query look here category args