WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How can I add target="_blank" for the WordPress credits in 2011 Theme? (8 posts)

  1. 5high
    Member
    Posted 1 year ago #

    Hi,

    I've searched the codex and the forums and surprisingly have found nothing about this!

    What I'd like to do is to get the WordPress credits link to open in a new tab - pretty standard practice I believe, when clicking a link to a different site. However all I've found is info about removing/disabling it! I presume I'd put in something like: target="_blank" though I've read that it's not valid now??

    The only place I can find to put it in the Twenty Eleven theme is in the Footer.php file, in the code below:

    <div id="site-generator">
    				<?php do_action( 'twentyeleven_credits' ); ?>
    				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
    			</div>

    but I'm not sure how to add it into a php file (only in html).
    I already have a child theme with a functions.php file (though nothing in it as yet!), but I'm at a complete loss as to how to do this probably very simple thing!
    I did have a go, and tried it here...

    <div id="site-generator">
    				<?php do_action( 'twentyeleven_credits' ); ?>
    				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven', target="_blank" ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
    			</div>

    but it must have broken it totally as I ended up with no footer at all!

    So any help would be greatly appreciated - and I'm sure it would be something that others are possibly interested in too...

    Thanks in advance.

  2. 5high
    Member
    Posted 1 year ago #

    Hi,
    any help with this would be really appreciated...
    Thanks.

  3. Bloke
    Member
    Posted 1 year ago #

    Try this. And then view your HTML code and see how it renders. If it doesn't work. You may have to escape some of the quotes.

    <div id="site-generator">
    				<?php do_action( 'twentyeleven_credits' ); ?>
    				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven' ) ) . '"target="_blank"' .; ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
  4. viky081
    Member
    Posted 1 year ago #

    <div id="site-generator">
    				<?php do_action( 'twentyeleven_credits' ); ?>
    				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven') ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?> "target="_blank"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
    			</div>

    Try this

  5. 5high
    Member
    Posted 1 year ago #

    Thanks very much for both those suggestions - I'll hopefully have a chance to look at it shortly and will let you know how they work.
    Have a Happy Christmas!

  6. 5high
    Member
    Posted 1 year ago #

    Hi Bloke and viky081,

    Just to let you know that it now works!
    I tried both of the code options you suggested, including some extra edits/guesses by me - all with no effect whatsoever... Then i thought I'd try it in a child footer.php file, rather than my function.php file in my child theme - and BINGO - it worked first time! I've only tried Bloke's one for this, and have removed an extra '.' before the semi-colon after the taget=blank edit.

    So I've copied the whole footer.php file and then edited it - as I wasn't 100% sure if I could only put a part of it in with the edits. So it now looks like this:

    </div><!-- #main -->
    	<footer id="colophon" role="contentinfo">
    			<?php
    				/* A sidebar in the footer? Yep. You can can customize
    				 * your footer with three columns of widgets.
    				 */
    				if ( ! is_404() )
    					get_sidebar( 'footer' );
    			?>
    			<div id="site-generator">
    				<?php do_action( 'twentyeleven_credits' ); ?>
    				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven' ) ) . '"target="_blank"' ; ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
    			</div>
    	</footer><!-- #colophon -->
    </div><!-- #page -->
    <?php wp_footer(); ?>
    </body>
    </html>

    ...though I'm slightly confused as to why the footer.php file has the above html in, as I thought php files weren't meant to have any in and the main functions.php file has none in.

    if you think I can cut anything out to make it less cluttered I'd be interested - and hopefully it'll be useful for others too?

    Many thanks for your help and support.

    Happy New Year!

  7. 5high
    Member
    Posted 1 year ago #

    hi again,
    i've just tried checking one of my pages on the W3C validator, and it's shown lots of errors relating to the edited code as above. I've tried to fix it but it all appears in html so I can't see what to fix in the php code.

    i'd really appreciate your feedback regarding this - if you input http://trevorpenfold.com/about-tp/ as the url into this site http://validator.w3.org/ it then throws up this list of errors:-

    Line 320, Column 40: No space between attributes.
    …				<a href="http://wordpress.org/"target="_blank"" title="Semantic Persona…
    Error Line 320, Column 55: No space between attributes.
    …"http://wordpress.org/"target="_blank"" title="Semantic Personal Publishing Pl…
    Line 320, Column 55: Saw " when expecting an attribute name. Probable cause: = missing immediately before.
    …"http://wordpress.org/"target="_blank"" title="Semantic Personal Publishing Pl…
    Line 320, Column 102: Attribute " is not serializable as XML 1.0.
    … title="Semantic Personal Publishing Platform">Proudly powered by WordPress</a>

    and

    Line 320, Column 102: Attribute " not allowed on element a at this point.
    … title="Semantic Personal Publishing Platform">Proudly powered by WordPress</a>
    Attributes for element a:
        Global attributes
        href
        target
        rel
        media
        hreflang
        type

    Any ideas??

    Thanks.

  8. 5high
    Member
    Posted 12 months ago #

    Hi,
    Just thought I'd give some feedback in case anyone's interested for twentytwelve child theme as well, I've fiddled around with different variables and found that this definitely works fine, in a child footer.php file:

    </div><!-- #main .wrapper -->
    	<footer id="colophon" role="contentinfo">
    		<div class="site-info">
    			<?php do_action( 'twentytwelve_credits' ); ?>
    			<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentytwelve' ) ) .'"target="_blank"'; ?>" title="<?php esc_attr_e( 'WordPress Publishing Platform', 'twentytwelve' ); ?>"><?php printf( __( 'Powered by %s', 'twentytwelve' ), 'WordPress' ); ?></a>
    		</div><!-- .site-info -->
    	</footer><!-- #colophon -->
    </div><!-- #page -->

    though I've changed some of the wording, as I prefer it to the original.
    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic