1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to insert a randomly chosen link into a post?

Discussion in 'General Scripting Chat' started by egomOnia, Apr 18, 2010.

  1. egomOnia

    egomOnia Registered Member

    Joined:
    Oct 21, 2009
    Messages:
    92
    Likes Received:
    62
    I'd like to add one static (!) link to each post on one of my blogs. The link should be chosen randomly from a list I create.

    The list would basically look like this:

    Code:
    <a href="URL1" title="TITLE1">ANCHOR1</a>
    <a href="URL2" title="TITLE2">ANCHOR2</a>
    <a href="URL3" title="TITLE3">ANCHOR3</a>
    etc.
    I can easily add an automatically created, randomly chosen, dynamic (!) link to every post. But how can I make it static? I need the link to be chosen only once from the link list when the post is created.. so it will be static, without changing each time you load the specific post.

    Can anyone please help me out here? I desperately need a solution for this.
     
  2. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,387
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    I don't have an answer for you, but I'm just a little bit curious. If it is just going to be a randomly chosen link, then why do you need it to be permanently assigned to that post? What's the reasoning behind not just letting it be randomly chosen each time the page loads?
     
  3. egomOnia

    egomOnia Registered Member

    Joined:
    Oct 21, 2009
    Messages:
    92
    Likes Received:
    62
    I need it for an autoblog which, for example, publishes 5 posts about 'acne' (just an example..) per day.

    In each post, at the end of the post body, I want one external link pointing at my main site or one of my posts on the main site (which is also about 'acne' but with unique articles..).

    So my autoblog boosts my main site with thematically relevant links with proper anchor text. This works nicely for my needs. I usually just added a link to my main site to the post body or the site footer, with the same anchor text all over the site.

    But I want to give this a little twist and give a little boost to my whole main site with different anchor texts and different links. Example:

    Code:
    <a href="www.acne.com" title="Acne">Acne</a>
    <a href="www.acne.com" title="Acne">Acne Cure</a>
    <a href="www.acne.com" title="Acne">Acne Solution</a>
    ..but also:

    Code:
    <a href="www.acne.com/home-remedies/" title="Acne Home Remedies">Acne Home Remedies</a>
    <a href="www.acne.com/natural-remedies/" title="Natural Acne Remedies">Natural Remedies for Acne</a>
    <a href="www.acne.com/cremes-for-acne/" title="Acne Creams">Anti Acne Cream</a>
    So I'll get a ton of thematically relevant links and deep links with all kinds of different anchor texts.

    Note: I know how do this by checking for a certain keyword in the post title. For example, if the post title contains "home remedies", I could add a link to my post on home remedies on my actual site. If it doesn't contain any previously specified keywords in the title, I could simply add a link pointing directly at the actual site. But I'd like to simply automate this after setting up the link list once, I don't want to waste too much time with this.
     
    Last edited: Apr 19, 2010
  4. egomOnia

    egomOnia Registered Member

    Joined:
    Oct 21, 2009
    Messages:
    92
    Likes Received:
    62
    Does anyone have an idea? I'm still trying to figure this out.