Support » Fixing WordPress » is_single problem!

  • Resolved gxt


    I’m having problems with is_single()

    The problem is that is_single() is supposed to work only on posts, NO “pages” and “attachments”, if I understand it right. Because if not there will be no difference between is_single and is_singular

    is_single() returns true if any single post is being displayed
    is_singular() returns true when any page, attachment, or single post is being displayed.

    But If I try to include a file only into a POST

    <?php if ( is_single() ) { ?>
    	<link rel="stylesheet" href="style.css" />
    <?php } ?>

    the css file appears also on attachment pages AND THAT AINT SUPPOSED TO HAPPEN.

    Is there a bug in wordpress or I’m doing something wrong?!!

    Thank you!

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


    Forum Moderator

    Are your attachments pointing to POST pages when you insert them?

    when I insert images I use
    [gallery columns="1" size="large"]
    then in the post, images (somename-500×550.jpg) point to the original image (somename.jpg) not to the attachment page.



    Forum Moderator

    Can we see one of these attachment links & pages?

    it’s not online yet. But problem was solved
    – 2 ways to exclude attachments from POSTS and get a file only and exclusively on POSTS.
    – 1:

    <?php if ( is_single() && !is_attachment() ) { ?>
        <link rel="stylesheet" href="style.css" />
    <?php } ?>

    – 2 way:

    <?php if ( is_singular('post') ) { ?>
        <link rel="stylesheet" href="style.css" />
    <?php } ?>

    I suggest the second way.

    Thanks to wordpress.stackexchange for the help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘is_single problem!’ is closed to new replies.