Support » Plugin: WordPress MU Sitewide Tags Pages » [Plugin: WordPress MU Sitewide Tags Pages] Displaying Blogname in Sitewide Post Headlines

  • Hi,
    I’m trying to work out a way to display the blog/site name above the post title on the home page my ‘global tags’ blog.

    This way I can differentiate where each post has originated from when viewed in the aggregated sitewide view.

    I tested this code:
    echo '<div id="blog_name"> ' . get_bloginfo ( 'name' ) . ' </div> ';
    but that displays the blogname for the ‘global tags’ blog and not the source of the content.

    thanks for your help.

    Paul

    http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Here’s what I have, (since blogid is in postmeta with this plugin):

    <?php
    $org_blog_id = get_post_meta ($post->ID, 'blogid', true);
    if($org_blog_id) {
    $blog_details = get_blog_details($org_blog_id);
    echo '  from <a href="' . $blog_details->siteurl . '">' . $blog_details->blogname . '</a>';
    }
    ?>

    Thread Starter closed account

    (@member11)

    Thanks David.

    That may work – although not for me yet.

    I’m actually trying to blend it in with a custom-function using Thesis theme. I’ll be asking there as well.

    Here’s what I’ve been working with so far:

    function my_teaser_byline() {
        global $thesis_design;
        $date_formats = thesis_get_date_formats();
        $use_format = ($thesis_design->teasers['date']['format'] == 'custom') ? $thesis_design->teasers['date']['custom'] : $date_formats[$thesis_design->teasers['date']['format']];
        echo '<div id="blog_name"> ' . get_bloginfo ( 'name' ) . ' </div> ';
        echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . '</abbr>  |  ' . "\n";
            $categories = get_the_category();
        echo '<a class="teaser_category" href="' . get_category_link($categories[0]->cat_ID) . '">' . $categories[0]->cat_name . '</a>' . "\n";
    }
    add_action('thesis_hook_before_teaser_headline', 'my_teaser_byline');

    If there is a way to blend your solution in with what I have here then it would be great – and even better would be if the blogid also linked back to the particular blog. 🙂

    thanks for your help.

    Paul

    In order to get the $post->ID, you may have to global $post. Or you could use get_the_id()

    $org_blog_id = get_post_meta(get_the_id(), 'blogid', true);

    Thread Starter closed account

    (@member11)

    Thanks David.

    I’m not the coding type…

    Can you please show me how to re-write that back into the function above.
    i.e. is replacing echo '<div id="blog_name"> ' . get_bloginfo ( 'name' ) . ' </div> ';
    with $org_blog_id = get_post_meta(get_the_id(), 'blogid', true);
    going to be enough?

    function my_teaser_byline() {
        global $thesis_design;
        $date_formats = thesis_get_date_formats();
        $use_format = ($thesis_design->teasers['date']['format'] == 'custom') ? $thesis_design->teasers['date']['custom'] : $date_formats[$thesis_design->teasers['date']['format']];
    
    //begin blend
    $postid = get_the_id();
    $org_blog_id = get_post_meta( $postid, 'blogid', true);
    if($org_blog_id) {
    $blog_details = get_blog_details($org_blog_id);
    echo '<div id="blogname-' . $postid . '">  from <a href="' . $blog_details->siteurl . '">' . $blog_details->blogname . '</a></div> ';
    }
    //end blend
    
        echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . '</abbr>  |  ' . "\n";
            $categories = get_the_category();
        echo '<a class="teaser_category" href="' . get_category_link($categories[0]->cat_ID) . '">' . $categories[0]->cat_name . '</a>' . "\n";
    }
    add_action('thesis_hook_before_teaser_headline', 'my_teaser_byline');
    Thread Starter closed account

    (@member11)

    thanks David. That worked perfectly – almost 🙂

    Only problem is that the <div id=”blogname- is pulling in the post id instead of the blog id.

    The blognames are displaying correctly but when I apply styling it matches it to the post id, meaning that other posts from the same blog aren’t picking up the same styling.
    For example these two posts are from the same blog but the div starts as follows:
    <div id=”blogname-46″>
    <div id=”blogname-38″>

    Any ideas?

    Thanks again.

    Add a class to the div (so you don;t have more than one div on the page with the same id), but style the class

    <div id="blogname-' . $postid . ' class="blogname"">

    so all blognames get the same style.

    Then in your css change
    #blogname {foo;}
    to
    .blogname {bar;}

    Thread Starter closed account

    (@member11)

    really appreciate your time on this David.

    I’m actually wanting different styling for each blog though rather than the same style for each.

    Any ideas? Thanks again.

    Sorry, I know no way to dynamically render unique styles for potentially 100s of different blognames in a css stylesheet. If the div is a blogname, all blogname divs get same style is what I have. Not sure what you are after. But you do have blognames for each post title now.

    Now, if all posts from the same blog were aggregated within the same div on the tags page, sure. But you would need to get multiple loops to query posts from one blog at a time.

    ie on the tags blog adding

    query_posts('meta_key=blogid&meta_value=63');

    before the start of the loop will return posts only from blog 63.

    Thread Starter closed account

    (@member11)

    ok. i think i’ll leave it there then. thanks very much for your help.

    I know it’s been ten months since you guys have visited this issue…

    David, your original code worked great, except it does not pull the blog name for the parent blog (I should mention I’m using Sitewide tags to display all the posts in a loop on the main theme).

    Any ideas?

    I does display all of the other blog names.

    Thanks so much.

    J

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WordPress MU Sitewide Tags Pages] Displaying Blogname in Sitewide Post Headlines’ is closed to new replies.