Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

How to put code in loop with instruction for single.php?


  #1  
Old Sep 2, 2010, 07:47 AM
annsworld
 
140 posts · Mar 2010
Hi,

I want to add a code in each post after the first paragraph. After searching on the internet, I found instructions on how to do that. The isntructions, however, change it in the single.php file.

I think I need to change this in the ATO section (right??):

So I went to ATO / Centre columnd / Style & Edit centre column.

And here is where I get stuck.

The instructions state to replace
Code:
<?php the_content(); ?>
And I cannot find that. So what do I replace instead? Or where do I copy the code in? Or am I totally wrong about this??

Here is the code I should replace the above with:
Code:
<?php
$show_after_p = 1;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
	$contents = explode("</p>", $content);
	$p_count = 0;
	foreach($contents as $content)
	{
		echo $content;

		if($p_count == $show_after_p)
		{
		?>
                INSERT ADSENSE CODE or Any other ads code
		<?
		}
		echo "</p>";
		$p_count++;
	}
}
?>
Thanks in advance for your help!
Ann.
  #2  
Old Sep 5, 2010, 09:41 PM
annsworld
 
140 posts · Mar 2010
Hello???

Can't really anyone help me here?

Ann.
  #3  
Old Sep 5, 2010, 11:41 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Look at ato->style & edit center area
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #4  
Old Nov 30, 2012, 06:54 AM
uomehero
 
1 posts · Nov 2012
Quote:
Originally Posted by juggledad
Look at ato->style & edit center area
I know it's very late to reply. I had the same problem and I searched on google and brought me to this page. I tried to combine and this is the result. Hope can help who have the same problem.

Look at Atahualpa Theme Options > Center Column > Style & edit CENTER COLUMN

Then look at The Loop, search :

Code:
<?php bfa_post_byline('<div class="post-byline">','</div>'); ?>

<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>

<?php bfa_post_pagination('<p class="post-pagination"><strong>'.__('Pages:','atahualpa').'</strong>','</p>'); ?>
then I modified <?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?> become.

Code:
<?php bfa_post_byline('<div class="post-byline">','</div>'); ?>

<?php if ( is_404() || is_home () || is_single() || is_category() || is_search() || is_page() ) {
            ?> 
            <?php /* If this is a 404 page */ if (is_404()) { ?>            
                        <?php /* If this is a home */ } elseif (is_home()) { ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php /* If this is a single post */ } elseif (is_single()) { ?>
<?php
$show_after_p = 1;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
	$contents = explode("</p>", $content);
	$p_count = 0;
	foreach($contents as $content)
	{
		echo $content;

		if($p_count == $show_after_p)
		{
		?>
                INSERT ADSENSE CODE or Any other ads code
		<?
		}
		echo "</p>";
		$p_count++;
	}
}
?>
<?php /* If this is a category archive */ } elseif (is_category()) { ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php /* If this is a pages */ } elseif (is_page()) { ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php }?>
<?php }?>

<?php bfa_post_pagination('<p class="post-pagination"><strong>'.__('Pages:','atahualpa').'</strong>','</p>'); ?>
***sorry for my english.
  #5  
Old Nov 30, 2012, 05:43 PM
rickheck
 
139 posts · Oct 2009
I modified STB's version of Juggledad's excellent "JUGGLEDAD's multi column/custom query" template ( I think I got that provenance correct) to allow for entry of PHP code inside the page. A simple change to his template can insert can allow you to insert any PHP code (or a function) inside the loop.

I also used the STB version to modify the template to display posts in 'hunks of a week'. That template is here http://forum.bytesforall.com/showthread.php?t=16453 .

The point is that if you want to modify how posts are displayed by adding additional commands to a template. THe STB/Juggledad templates are a great place to start. And by using a template, you don't have to worry about changes that happen with theme updates. (As long as you remember to put your templates in the theme's folder.)

...Rick...
  #6  
Old Dec 1, 2012, 09:52 PM
rickheck
 
139 posts · Oct 2009
Glad I got the provenance right....

Interesting to note about the addition of the date-picking-thing in 3.6. The mod that I made to the template taught be quite a bit about the process. I am using that knowledge to even further mod the template for my own uses.

My current version allows me to add custom functions and CSS to the output, with only minor mods to the index.php page. The mods allow me to add PHP code wherever I want within the loop, like it used to be in prior versions of ATA. And I have used additional custom fields for other purposes in my template.

The whole thing is built modular, so it is easy to customize the pages.

Which is a bit off-topic, but shows the versatility of the template process. For anyone that is interested in seeing the results of a 'weekly' extract of posts, they can go here: http://www.jerrypournelle.com/chaosmanor . Look at the choices under "View" and "Mail".

...Rick...

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add PHP to the loop on multi- and single post pages only? Fux Center area post/pages 2 Jun 16, 2010 04:55 AM
How to add php code to a 'single' page JakeThePeg Center area post/pages 8 Mar 21, 2010 01:21 AM
Weird Error With Code in Loop as Opposed to index.php adum Post-Kicker, -Byline & -Footer 1 Oct 10, 2009 04:48 AM
Loop Code Displaying Instead of Pages TheInfamousGdub Atahualpa 3 Wordpress theme 6 Aug 27, 2009 08:52 PM
[SOLVED] No sidebar.php...where do I put the code? d_random Atahualpa 3 Wordpress theme 0 Apr 3, 2009 12:42 PM


All times are GMT -6. The time now is 02:48 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.