The MU forums have moved to WordPress.org

Vars for href and title (main domain)? (5 posts)

  1. macworkshop
    Member
    Posted 15 years ago #

    Hi all,

    You know what gets my goat? When you can't find the vars you're looking for. For those that got the reference - :o))

    This is my header image code:

    <a href="http://rationalbritain.org/" title="Home (RationalBritain)" rel="home"><img src="<?php bloginfo('template_directory') ?>/img/header/headerimage.jpg"></img></a> <!-- ToDo: change href & title to vars - [$james - 14/2/09 @ 14:28] -->
    				<br />
    
    				<?php global $blog_id ?> <!-- declare blog var for conditional below - [$james - 14/2/09 @ 14:00] -->
    				<?php if ($blog_id !=1) { ?> <!-- conditional for blog description display - [$james - 14/2/09 @ 14:00] -->
    				<strong id="blog-title"><a href="<?php bloginfo('url') ?>/" title="Home (<?php bloginfo('name') ?>)" rel="home"><?php bloginfo('name') ?></a></strong>
    				<?php } ?> <!-- /conditional - [$james - 14/2/09 @ 14:00] -->
    
    				<p id="blog-description"><?php bloginfo('description'); ?></p>

    Hopefully you see what I'm doing - Main domain image at top of header, links to home of main blog; description text of current blog below, links to home of current blog.

    I want to replace the href and title attributes with the relevant vars - this template will be rolled out to a few domains, and I don't want to be hard-coding links and domain names each time.

    $domain returns the current blog domain - with subdomain. I simply want the var for the main domain, whatever blog is being viewed.

    I can't find the current blog title var either - am I just being blind?

    Thanks in advance.

  2. andrea_r
    Moderator
    Posted 15 years ago #

    You don't need all that. If you just put in <?php bloginfo('url') ?> without any conditions, it'll display the one you're on.

  3. SteveAtty
    Member
    Posted 15 years ago #

    I've always found

    http://codex.wordpress.org/WPMU_Functions

    a useful resource

    and

    http://codex.wordpress.org/WPMU_Functions/get_blog_details

    contains everything I think you'll need

  4. macworkshop
    Member
    Posted 15 years ago #

    Awesome - thanks guys!

  5. macworkshop
    Member
    Posted 15 years ago #

    Nailed it. For anyone else who was struggling with this:

    <div id="header">
    			<div class="wrapper">
    				<a href="<?php _e(get_blogaddress_by_id('1')); ?>" title="Home (<?php _e(get_blog_option(1,'blogname')); ?>)" rel="home"><img src="<?php bloginfo('template_directory') ?>/img/header/headerimage.jpg"></img></a> <!-- using vars here, to echo URL and blog name for main site (so we can port this theme without hard links or static descriptions) - [$james - 17/2/09 @ 12:57] -->
    				<br />
    
    				<?php global $blog_id ?> <!-- declare blog var for conditional below - [$james - 14/2/09 @ 14:00] -->
    				<?php if ($blog_id !=1) { ?> <!-- conditional for blog description display - [$james - 14/2/09 @ 14:00] -->
    				<strong id="blog-title"><a href="<?php bloginfo('url') ?>/" title="Home (<?php bloginfo('name') ?>)" rel="home"><?php bloginfo('name') ?></a></strong>
    				<?php } ?> <!-- /conditional - [$james - 14/2/09 @ 14:00] -->
    
    				<p id="blog-description"><?php bloginfo('description'); ?></p>
    				<div id="navigation">
    					<ul>
    						<?php wp_list_pages('title_li='); ?>
    						<li class="secondary"><?php wp_loginout(); ?></li>
    						<?php wp_register('<li class="secondary">', '</li>'); ?>
    					</ul>
    				</div><!-- #navigation -->
    			</div><!-- .wrapper -->
    		</div><!-- #header -->

About this Topic

  • Started 15 years ago by macworkshop
  • Latest reply from macworkshop