Where to add code? Single.php?

General questions pertaining to how certain issues can be resolved. This forum is closed with effect from February 2019. Please post future requests on https://github.com/sayontan/suffusion.
Forum rules
This forum is closed with effect from February 2019. Please post future requests on https://github.com/sayontan/suffusion.

1. No offensive language and no mocking
2. Please do a thorough search before you post something. Trust us, there is a high probability that the question you are asking has been asked previously.
3. No soliciting. You cannot post here soliciting bids for people offer you quotes, or even offer money to people for some work. You will be moderated if you do so. If you are looking for help, please post your request on http://jobs.wordpress.net or http://codepoet.com
4. Please be reasonable. You are getting software and support. For free. Complicated requests from a general purpose theme are not welcome and some volunteers might lose patience with you.
5. Please do your due diligence. If you posted a query and we answered with a link, take the trouble to go through the link contents.
6. Please post with complete information. Requests for help MUST be accompanied with your URL, particularly if you are asking something like "Why am I seeing a blank space?"
Locked
thedownsclan
Posts: 6
Joined: 21 Apr 2010, 21:23

Where to add code? Single.php?

Post by thedownsclan » 21 Apr 2010, 21:34

Hello,

I've read every article that has the word single.php but I still can find the solution.

My issue is that I can't seem to add the code for the Facebook Like button:

Code: Select all

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show_faces=true&width=260&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:260px; height:px"></iframe>
I would like to add it to the php page that controls every post. I would like to it to the top, right below post's title. I looked at the single.php but it talks about a "Single book template for the Now Reading plugin." I noticed that in other topics, you mentioned the 'div="post_nav"' (or something like that - I forgot on what post I saw it, but don't want to navigate away from writing this) in the single.php but I can't find anything similar to that.

So where would I add the code so that it will show up on each post, but only when the user clicks on the post? So for example, when you go to the main page, it'll lists all posts, but the user won't see the Facebook Like button until he clicks and views the individual post.

Any assistance is great appreciated.

http://www.thedownsclan.com

User avatar
Connie
Posts: 1169
Joined: 10 Nov 2009, 04:53
Contact:

Re: Where to add code? Single.php?

Post by Connie » 22 Apr 2010, 02:09

1) edting the core files of the theme is not recommended, not update-proof

2) Suffusion supports Social Networks, go to Blog Features / User Profiles / Select Additional Social Networks

so there is not need to edit anything ;)

thedownsclan
Posts: 6
Joined: 21 Apr 2010, 21:23

Re: Where to add code? Single.php?

Post by thedownsclan » 22 Apr 2010, 03:33

Suffusion does support Social Networks, but only to the point that it will show an icon linking from your site to your Social Network account. For example, when you "enable" this feature in Suffusion, a Facebook icon will show, and when you click it, it will link you to my Facebook account www.facebook.com/alexanderdowns

Although nice, that's not the functionality I would like. The code I mentioned above creates a "Like" button (see http://developers.facebook.com/docs/ref ... ugins/like). I can place this on the header.php but it will "Like" the entire site rather than the individual posts even when viewing a single post. So in essence, by placing the Facebook code into the .php page that controls the individual post, when users click on the "Like" button, they will only "Like" that one post. This "Like" feature will give exposure to potentially hundreds of new visitors.

Please help. Thanks,

Alex

User avatar
Connie
Posts: 1169
Joined: 10 Nov 2009, 04:53
Contact:

Re: Where to add code? Single.php?

Post by Connie » 22 Apr 2010, 03:52

I would suggest to use a Plugin for this.

For example this one: http://wordpress.org/extend/plugins/social-buttons/

do a search like this and you find many many possibilties:

http://wordpress.org/extend/plugins/sea ... work&sort=

I do not understand why you don't look for a plugin first, as most of these demands are realized already

thedownsclan
Posts: 6
Joined: 21 Apr 2010, 21:23

Re: Where to add code? Single.php?

Post by thedownsclan » 22 Apr 2010, 04:23

I actually did see that plugin and others before posting here (I did my due diligence). However, it does not do what the code provided by Facebook does, which is the following:

When the user click on the "Like" button, the user's profile on Facebook will show a stream update stating
"Connie likes Alex's "Suffusions helps Alex put code into individual posts" on thedownsclan.com"
. Additionally, the user's picture will show up on the iframe that the code provides on my site. A message will appear for other users who are friends of Connie when they visit my site stating
"Connie likes this post. Like it also"
And so the cycle will continue.

This is different that what the plugins do: for example, the plugins have a "Share" function (which I already have) which will send the post into the user's wall and that's it. It's not interactive like the Facebook code. This code is new and was release by Facebook yesterday and it's very simple to integrate... provided you know where to put it.

Any help...? Pretty please..?

sayontan
Site Admin
Posts: 10210
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas
Contact:

Re: Where to add code? Single.php?

Post by sayontan » 22 Apr 2010, 06:24

The single.php file you are referring to is in the "suffusion/now-reading" folder. Use the file in the "suffusion" folder. You can control which file to use by editing the URL in the theme editor.

thedownsclan
Posts: 6
Joined: 21 Apr 2010, 21:23

Re: Where to add code? Single.php?

Post by thedownsclan » 22 Apr 2010, 09:59

sayontan wrote:The single.php file you are referring to is in the "suffusion/now-reading" folder. Use the file in the "suffusion" folder. You can control which file to use by editing the URL in the theme editor.
You mentioned to use the file "Suffusion" folder and I have located the single.php file. However, everything in there seems to talk about the Book Template. There is no <div id="post1234"> for example. All the php code seems to be referring to books, libraries, etc. I have the Magazine Template disabled and don't have the Now Reading plugin because I don't have "Book Club" type of site.

Furthermore, you stated "You can control which file to use by editing the URL in the theme editor". I cannot find where to do this on the Theme Options wizard or the Editor itself. But what exactly will I edit? And what URL? I'm not sure what you meant by that.

Below is the single.php:

Code: Select all

<?php
/**
 * Single book template for the Now Reading plugin.
 *
 * @package Suffusion
 * @subpackage NowReading
 */

get_header();
global $nr_id, $suffusion;

$suf_nr_single_added_show = $suffusion->option('suf_nr_single_added_show');
$suf_nr_single_started_show = $suffusion->option('suf_nr_single_started_show');
$suf_nr_single_finished_show = $suffusion->option('suf_nr_single_finished_show');
$suf_nr_single_meta_show = $suffusion->option('suf_nr_single_meta_show');
$suf_nr_single_added_text = $suffusion->option('suf_nr_single_added_text');
$suf_nr_single_started_text = $suffusion->option('suf_nr_single_started_text');
$suf_nr_single_finished_text = $suffusion->option('suf_nr_single_finished_text');
?>

<div id="main-col">
<?php suffusion_before_begin_content(); ?>
	<div id="content">
<?php suffusion_after_begin_content(); ?>
        <div class="post fix nr-post">
<?php
if( have_books(intval($nr_id)) ) {
	while ( have_books(intval($nr_id)) ) {
		the_book();
?>
        <h1 class="posttitle"><?php book_title(); ?></h1>

		<div class="bookdata fix">
			<div class="author">
				<a href="<?php book_author_permalink() ?>"><?php book_author() ?></a>
			</div>

			<div class="rating">
				Rating: <?php echo book_rating(false); ?>
<!--				<img src="<?php bloginfo('stylesheet_directory')?>/images/<?php book_rating() ?>.png" height="20px" title="Rating: <?php book_rating()?>" alt="Rating: <?php book_rating()?>" />-->
			</div>
<?php
		if( can_now_reading_admin() ) {
?>
			<div class="edit">
				<a href="<?php book_edit_url(); ?>">Edit this book</a>
			</div>

			<div class="manage">
				<a href="<?php manage_library_url(); ?>"><?php _e('Manage Books', NRTD);?></a>
			</div>
<?php
		}
?>
		</div>

		<div class="bookentry fix">
			<div class="stats">
				<a href="<?php book_url(); ?>" title="<?php if (!is_custom_book()) { ?>Buy <?php book_title();?> from Amazon<?php }?>"><img src="<?php book_image(); ?>" alt="<?php book_title(); ?>" /></a>
				<br/>
				<p>
<?php
		if ($suf_nr_single_added_show == 'show') {
				echo $suf_nr_single_added_text;
				echo book_added(false);
?>
				</p>
				<p>
<?php
		}
		if ($suf_nr_single_started_show == 'show') {
			echo $suf_nr_single_started_text;
			echo book_started(false);
?>
				</p>
				<p>
<?php
		}
		if ($suf_nr_single_finished_show == 'show') {
			echo $suf_nr_single_finished_text;
			echo book_finished(false);
?>
				</p>
				<p>
<?php
		}
		if ($suf_nr_single_meta_show == 'show') {
?>
					<?php print_book_meta(0); ?>
<?php
		}
?>
				</p>
			</div>

			<div class="review">
<?php
		book_review();
		if(book_has_post()) {
?>
				<p>This book is linked with the post <a href="<?php book_post_url() ?>">&ldquo;<?php book_post_title() ?>&rdquo;</a>.</p>
<?php
		}
?>
			</div><!--/.review -->

		<?php
			$tags = print_book_tags(false);
			if (trim($tags) != "") {
		?>
			<div class="post-footer fix">
				<span class="tags"><?php _e('Tagged with: ', 'suf_theme'); print_book_tags(1); ?></span>
			</div><!--/.post-footer -->
		<?php
			}
		?>
		</div><!-- bookentry -->
<?php
	}
}
else {
?>
		<h2 class='posttitle'><?php _e("Not Found", "suf_theme"); ?></h2>
		<div class='entry'>
			<p><?php _e("Sorry, but you are looking for something that isn't here", "suf_theme"); ?></p>
		</div>
<?php
}
//library_search_form();
?>

<!--		<p><a href="<?php library_url() ?>">&larr; Back to library</a></p>-->
	</div><!-- post -->

	</div><!-- content -->
</div><!-- left-col -->

<?php
get_footer();
?>
Thanks for the help. :roll:

sayontan
Site Admin
Posts: 10210
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas
Contact:

Re: Where to add code? Single.php?

Post by sayontan » 22 Apr 2010, 10:06

When you go to Appearance -> Editor you see a list of theme files. If you click on single.php the URL it takes you to is:

http://.../wp/wp-admin/theme-editor.php?file=/themes/suffusion/now-reading/single.php&theme=Suffusion&dir=theme

On your browser's address bar change this to:

http://.../wp/wp-admin/theme-editor.php?file=/themes/suffusion/single.php&theme=Suffusion&dir=theme

thedownsclan
Posts: 6
Joined: 21 Apr 2010, 21:23

Re: Where to add code? Single.php?

Post by thedownsclan » 22 Apr 2010, 10:27

I just really want to thank you soooo much for your assistance!

Locked