• Resolved strava1

    (@strava1)


    Hi there
    I have problem with showing category posts on diferent page.

    When i make this code he works perfectly

    <?php
    if (is_page('modeli-torbica')) {
      $cat=get_cat_ID($post->post_title); //use page title to get a category ID
      $posts = get_posts ("cat=$cat&showposts=10");

    But when I add elseif for my second page it show anything.
    I wona show on two diferent pages,two diferent category.

    <?php
    if (is_page('modeli-torbica')) {
      $cat=get_cat_ID($post->post_title); //use page title to get a category ID
      $posts = get_posts ("cat=$cat&showposts=10");
    
       <?php
    elseif (is_page('modeli-nakita')) {
      $cat=get_cat_ID($post->post_title); //use page title to get a category ID
      $posts = get_posts ("cat=$cat&showposts=10");

    Where I make wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You didn’t have a closing } before the elseif() so that’s considered part of the original if() statement.

    You’d need something like this:

    <?php if( is_page('modeli-torbica') ): ?>
        <p>First option</p>
    <?php elseif( is_page('modeli-nakita') ): ?>
        <p>Second option</p>
    <?php endif; ?>
    Thread Starter strava1

    (@strava1)

    Thanks catacaustic I am posted elseif into if{ }.

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

The topic ‘If is page elseif problem’ is closed to new replies.