WordPress.org

Ready to get started?Download WordPress

Forums

PHP code question (3 posts)

  1. cucalon.j
    Member
    Posted 1 year ago #

    I am trying to use two different style-sheets. One for the whole page, and a separate style-sheet for the shop page.

    I am new to php and I tried using this if else statement at the header, that does actually work but backwards.

    <?php if( is_page('shop-2') ) :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
    <?php else :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/shop.css" media="screen" />
    <?php endif;?>

    I was hoping someone knew enough php to help me invert it.I can't seem to find the right syntax for php.

    <?php if( is(NOT)_page('shop-2') ) :?>

    Thank you!

  2. michael.mariart
    Member
    Posted 1 year ago #

    You are close. The "not if" syntax is:

    if (!is_page('shop-2'))

    The ! means "if not true" pretty much.

  3. cucalon.j
    Member
    Posted 1 year ago #

    Michael,

    Thank you very, but very much. I had tried a few combinations of "is not", even is!_page. But I did not try the other way around. You just saved me hours and hours of more scrambling to fix such a small problem.

    I appreciate it immensely, sincerely. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic