Jump to content
Sign in to follow this  
kelbycarr

How to edit single post code?

Recommended Posts

cmunns

What you would want to edit is the template.postloop.php, but i recommend copying it into the Base Child theme if you're going to edit it. If you need help figuring out where in that file is appropriate let us know.

Share this post


Link to post
Share on other sites
kelbycarr

I had commented in a forum before, but I was never able to get Base working.

Share this post


Link to post
Share on other sites
kelbycarr

Oh, and yes, where to edit in that file would be great. I really don't want to mess anything up...

Share this post


Link to post
Share on other sites
cmunns

The line of code referenced in that article would be this `the_content(__('

Continue reading »

','pagelines'));?>` line 131 in template.postloop.php

Share this post


Link to post
Share on other sites
kelbycarr

So how would the code they reference here look then?

<?php
	$paragraphAfter= 1; //display after the first paragraph
	$content = apply_filters('the_content', get_the_content());
	$content = explode("</p>", $content);
	for ($i = 0; $i <count($content); $i++) {
	if ($i == $paragraphAfter) { ?>
	<div>
	
	Your add code here
	
	</div>
	<?php
	}
	echo $content[$i] . "</p>";
	} ?>

I don't see that you guys have a "php the_content" line so what part of your code line would I keep and what would I leave in? Or I guess what I am asking is what would my final code look like with the alteration above? Sorry to ask... I just want to be sure I do it properly.

Share this post


Link to post
Share on other sites
bryan-hadaway

Continued developer support soon... Thanks, Bryan

Share this post


Link to post
Share on other sites
cmunns

Did you try replacing the line of code I pointed out above near or around line 131 with the code provided in the article? you may have to leave out the opening `<?php` and the closing `?>` when you replace it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×