WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Sitewide Tags Pages
[resolved] Blog titles with links (15 posts)

  1. Tomas
    Member
    Posted 3 years ago #

    Awesome plugin!
    Just wonder if there's an easy way to print out the blog title each post is fetched from in the theme for the global blog.

    Like entry meta:

    <div class="entry-meta">
    <?php the_time( 'l F j, Y H:i' ) ?> // From blog: <the source blog title here>
    </div>

  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 3 years ago #

    You would need to write something for that. SWT doesn't pass that info through to the global blog.

  3. Tomas
    Member
    Posted 3 years ago #

    Thanks Ron, I came to that conclusion aswell.

    The post_meta table on the global blog only contains the blogid and permalink for each post so I'd probably need to customize the plugin which is just a little above my php knowledge ;)

  4. Michael Bishop

    Posted 3 years ago #

    I had a similar need, I wound up editing the SWT plugin to grab the title in the global_meta array. I'm still working on a way to do it without modifying the plugin but until then, this might help.

    Around line 367 of the SWT plugin I added $global_meta['blogtitle'] = get_bloginfo('title');

    and then where ever you want to output the title on your tags site echo (get_post_meta($post->ID, "blogtitle", true));

  5. Tomas
    Member
    Posted 3 years ago #

    miklb, this is fabulous info.
    Will have a try out later today

    Many many thanks!

  6. Tomas
    Member
    Posted 3 years ago #

    hmm, I'm not getting the expected output?!
    Instead of the blog title from the corresponding blog I get the global blog title on each post.
    miklb, would you consider sharing your modified plugin?

    tia
    Tomas

  7. Michael Bishop

    Posted 3 years ago #

    My version literally is the same plugin with that one line added. Can you confirm that the posts pushed to your tags blog is getting that post_meta field added with the the site title associated with the post?

    I'm not outputting the title in template, rather I'm creating a custom feed where I use the post_meta. If you can confirm the correct title is being added, I'll double check how I'm outputting the info.

  8. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 3 years ago #

    @miklb - there was quite a bit of rewriting in the latest version, so your line # might be off enough to be in the wrong place.

  9. Tomas
    Member
    Posted 3 years ago #

    @miklb - I get the blogtitle value in the post_meta now but it's always the global blog title and not the corresponding blog title.

    Maybe I put your code in the wrong place?
    From the plugin line 367:

    switch_to_blog( $tags_blog_id );
    
                    $global_meta['blogtitle'] = get_bloginfo('title');
    
            if( is_array( $cats ) && !empty( $cats ) ) {
                    foreach( $cats as $t => $d ) {
                            /* Here is where we insert the category */
                            wp_insert_category( array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => '') );
    
                            /* Now get the category ID to be used for the post */
                            $category_id[] = $wpdb->get_var( "SELECT term_id FROM " . $wpdb->get_blog_prefix( $tags_blog_id ) . "terms WHERE slug = '" . $d['slug'] . "'" );
                    }
            }
    
            $global_post = $wpdb->get_row( "SELECT * FROM {$wpdb->posts} WHERE guid = '{$post->guid}'" );
    
            if( $post->post_status != 'publish' && is_object( $global_post ) ) {
                    wp_delete_post( $global_post->ID );
            } else {
                    if( $global_post->ID != '' ) {
                            $post->ID = $global_post->ID; // editing an old post
  10. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 3 years ago #

    Move the line you added to before the switch_to_blog( ...

  11. Tomas
    Member
    Posted 3 years ago #

    Thanks Ron but sorry...no dice.
    Still same global blog title output on each post.

    Maybe I'm doing the loop wrong?
    In the theme file loop I have it like this (twentyten standard):

    [Code moderated as per the Forum Rules. Please use the pastebin]

  12. Tomas
    Member
    Posted 3 years ago #

    Opps, looks like it's actually working now (had a cache issue)

    Thank you both for your help :)

  13. Michael Bishop

    Posted 3 years ago #

    cool, sorry I didn't get back sooner. And thanks Ron on the heads up of the rewriting, I was working off a dev version still.

  14. Michael Bishop

    Posted 3 years ago #

    For future reference, for v.4.1.1 I added that after line 368 $global_meta['blogid'] = $org_blog_id = $wpdb->blogid; // org_blog_id

  15. Tomas
    Member
    Posted 3 years ago #

    Thanks for your input

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic