• wprun

    (@wordpressrun)


    Is it possible to target only post content ?

    for example I want to create a style for a (anchor link)

    and I want it to only apply to content that is updated in the post editor.

    I do not want it to apply to links that exist anywhere else on the site or pages either.

    Thanks!

    • This topic was modified 7 years ago by wprun.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Look at the <body> tag on a page (while viewing source) and you’ll see that posts and pages usually are assigned classes “post” and “page”, respectively. You can used those body classes as additional selectors for CSS to target posts or pages.

    Michael

    (@alchymyth)

    many themes possibly use post_class() in the surrounding element for a post;
    this would, for example, add a CSS class of .hentry which you could use to target only links within the content.

    i.e.:
    .hentry a { color: green; }

    also, to target POSTS only, follow up on the suggestion by @sterndata.

    i.e.:
    .post .hentry a { color: red; }

    additionally, your theme might already use more specific CSS for those links, and there might be other specific CSS selectors for the post content, which depends on your currently used theme – please post more details.

    andalusien

    (@andalusien)

    Hey Michael,

    thanks for your answer.

    I put in: .post .hentry a { color: #CD8162; }
    but it did not work.

    than I tried with: .post .hentry a { color: #CD8162!important }
    It did not work.
    The lines before are:

    }
    .bsaProContainer .bsaProItem:first-child, .bsaProContainer .bsaProItem.bsaReset {
    margin-left: 0.5% !important;
    }
    .post .hentry a { color: #CD8162!important }

    I would be happy if you could help me with that.

    Greatings

    Andalusien

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CSS targeting only post content’ is closed to new replies.