Support Forum

Need template tag to show forum link in blog post

SS Shawn S
Shawn S
Member

I have a site in the development stages. It was running WP 3.3 and SP 4.5 and I decided to upgrade to SP 5. When I originally installed SP, I had some display problems in my theme (iThemes Builder) so I used the template tags to insert the forum links on the blog posts instead of the automatic function (the auto function causes forum links to show up in widget areas that shouldn’t have them)

This is the code that worked in my theme in SP 4.5:

<?php global $post; 
sf_blog_linked_tag($post->ID, true); ?>

After upgrading to SP 5, the code now shows an error in my theme pages:

Fatal error: Call to undefined function sf_blog_linked_tag() in /problem-with-post-edit-buttonome/ninja/public_html/nbs/wp-content/themes/BuilderChild-Foundation-Blank/page.php on line 22

I’m guessing the template tag formats have changed for version 5 but after searching around the forum here, I haven’t found any solutions. I do have the template tag plugin installed and activated. Does anyone know what code I should use to replace the original template tag for showing the forum link?

13 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Because Blog Linking is now a plugin and not a part of the core then any template tags associated with Linking are now a part of the Linking package. You will find it has it’s own ‘template tags’ folder.

The one you want, I believe, is

spBlogTopicLinkTag($postid, $show_img);
SS Shawn S
Shawn S
Member

Ok, I’m no php expert so it is quite possible I have messed up somewhere but I replaced my original template tag code with this:

<?php spBlogTopicLinkTag($postid, $show_img=true); ?>

 

and I get the following error:

Fatal error: Call to undefined function spblogtopiclinktag() in /problem-with-post-edit-buttonome/ninja/public_html/nbs/wp-content/themes/BuilderChild-Foundation-Blank/page.php on line 21

I looked in the new template tags folder but as I said I’m no php expert. I can get the links to show up using the automatic function but not manually. What am I doing wrong?

MP Mr Papa
Mr Papa
Member

are you sure you replaced it exactly?  doesnt look like it…  the name is case sensitive…  ie you need the capital letters in the function Andy posted…

SS Shawn S
Shawn S
Member

Yes, I noticed that and thought it was strange so I double checked. The code I put in my template has the capital letters but the error code shows the lower case. Here is a copy and paste of the code as it exists in my page.php template:

                <!-- post content -->
                <div class="post-content">
                    <?php the_content(); ?>
                    <?php spBlogTopicLinkTag($postid, $show_img=true); ?>
                    <?php wp_link_pages( array( 'before' => '<p><strong>' . __( 'Pages:', 'it-l10n-Builder' ) . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number' ) ); ?>
                    
                </div>
            </div>
            <!-- end .post -->
MP Mr Papa
Mr Papa
Member

weird… but looking a bit deeper, I think you actually want to call:

oh, couple things, first, you have to replace the arguments with yours… you still have the function prototype there… show $postid should be the id of the post… and either true or false for second argument…

but I also think thats the wrong function to call… I dont think that is exposed… you need to call the wrapper function:

spBlogTopicLink

so it should look likek

spBlogTopicLink($post->ID, true);

if within the wp loop… or false if you dont want the image…

SS Shawn S
Shawn S
Member

Thanks, I tried the last one you listed:

<?php spBlogTopicLink($post->ID, true); ?>

and now I get a different error, but it at least seems to recognize the spBlogTopicLink now. Not sure what sf_esc_int is though:

Fatal error: Call to undefined function sf_esc_int() in /problem-with-post-edit-buttonome/ninja/public_html/nbs/wp-content/sp-resources/forum-plugins/blog-linking/template-tags/sp-linking-blog-tags.php on line 26
MP Mr Papa
Mr Papa
Member

argh…  thats a bug on our part… there are three of those in the blog linking plugin file referenced… if you could change them to:

sp_esc_int

it should work… I will fix them up and get them committed to svn…  should hopefully get an update out today…

SS Shawn S
Shawn S
Member

Ok, I made those three changes to the referenced file and now I get no errors but I also get no blog link displayed on my page.

 

Just to add additional information, I can turn on the option to “Create blog post to topic link automatically” and the link will show up perfectly. The reason this automatic option won’t work for me is because it causes the links to also appear in my theme’s “widget content” areas. This occurs despite having “widget_content” unchecked in the post types section listed under Post Linking.

YS Yellow Swordfish
Yellow Swordfish
Member

I am looking at it now. There are some other problems in there that we didn’t find. Will come back to you.

YS Yellow Swordfish
Yellow Swordfish
Member

Steve tells me he just pushed out another update for the blog linking plugin and now the tag should be OK. Worked for me just fine in tests here. Apologies for the hassle.

MP Mr Papa
Mr Papa
Member

yes, v1.0.4 of blog linking plugin is available in the wp updater…

SS Shawn S
Shawn S
Member

YEEEEAH!! That did it. Thanks very much guys.

For anyone else that may run into this problem, this is the exact code that I put in my single.php and page.php theme files, just after the loop.

<?php global $post; 
 spBlogTopicLink($post->ID, true); ?>
MP Mr Papa
Mr Papa
Member

good work. if it was in the wp loop, the $post should already be global… but that is fine…