SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make adverts automatically display in middle of content only on longer posts

    Hi. Does anyone know how to make an advert appear in the middle of content, but only when the post is a certain length? E.G. if a post is only 100 words long, there isn't enough room for an advert, but there would be room if it's 500 words, for example.

    Any ideas? thanks!

  2. #2
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,524
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    http://php.net/manual/en/function.str-word-count.php

    http://codex.wordpress.org/Function_...et_the_content

    Retrieve the content of the post/page, and use the standard PHP function to count the words.

    Then modify and echo the content as appropriate to display the content and your ad(s).
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •