Support » Plugins and Hacks » Hacks » proper syntax for using page_id

  • I have a child theme installed and a custom css file that I am using to make all of my edits. Currently I am trying to reference a certain page… page#825-2, it is a page not a post. I am trying to remove a boarder and a background color for an image on that page only. By default the theme that I am using puts a boarder and a background color within that boarder to surround all images. So far the code that I have is:

    .entry img {
    	padding: 0px;
    	border: 0px solid #e6e6e6;
    	background:#ffffff;
    }

    this code works but it applies itself to the site as a whole. I only want to apply to a certain page. What would the proper syntax be for this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, this is the correct syntax:

    .page-id-PAGEID .entry img {
    	padding: 0px;
    	border: 0px solid #e6e6e6;
    	background:#ffffff;
    }

    Assuming that your page id is 825 (you can find page id in the browser url bar, when editing that page), you would use this:

    .page-id-825 .entry img {
    	padding: 0px;
    	border: 0px solid #e6e6e6;
    	background:#ffffff;
    }

    @originalexe Thanks for the reply. The page id within the box when I am editing the page within WordPress is 825-2. Very confusing, I would think there would be a 825-1 or 825-3. I dropped the -2 from 825-2 to 825 as shown in your code. If I used:

    .page-id-825-2 .entry img {
    	padding: 0px;
    	border: 0px solid #e6e6e6;
    	background:#ffffff;
    }

    it would not work. But with:

    .page-id-825 .entry img {
    	padding: 0px;
    	border: 0px solid #e6e6e6;
    	background:#ffffff;
    }

    It works. Odd. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘proper syntax for using page_id’ is closed to new replies.