Forums

the_content - open a link in a new window (2 posts)

  1. rbernabe
    Member
    Posted 1 year ago #

    Hi Everyone

    I've searched for an answer but to no avail thus far. Im looking to open a link contained within a post in a new window, but however this new window should have a specific background color. So I cannot rely on the standard target attribute of the link tag, I need to include some javascript in that link.

    It seems I can't do what I want because the page just makes a call to the_content from within the loop, like so:

    <?php if (have_posts()) : while (have_posts()) : the_post(); // the loop ?>
    
    <!--post title-->
    <h1 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h1>
    
    <!--post text with the read more link-->
    <?php the_content('<div class="post-more">Read the rest of this entry &raquo;</div>'); ?>

    How can I modify part of the code that will appear in the returned value from the call to the_content? Right now, the source of the link I want to change is:

    <a href="blah">Link</a>

    And change it to this:

    <a href="blah" onClick="...">Link</a>

  2. webfwrd
    Member
    Posted 1 year ago #

    Actually you can just do like this:

    <?php the_content('<div class="post-more" onClick="...">Read the rest of this entry &raquo;</div>'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.