Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   How to put code in loop with instruction for single.php? (http://forum.bytesforall.com/showthread.php?t=9346)

annsworld Sep 2, 2010 07:47 AM

How to put code in loop with instruction for single.php?
 
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.

annsworld Sep 5, 2010 09:41 PM

Hello???

Can't really anyone help me here?

Ann.

juggledad Sep 5, 2010 11:41 PM

Look at ato->style & edit center area

uomehero Nov 30, 2012 06:54 AM

Quote:

Originally Posted by juggledad (Post 42558)
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.

rickheck Nov 30, 2012 05:43 PM

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...

rickheck Dec 1, 2012 09:52 PM

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...


All times are GMT -6. The time now is 02:06 PM.

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