Add something after first post
-
Hello
I have this question, i would like to add some html after first post and before third post , is there a easy solution to make it happend ?
-
Yes…almost. This will show something after the first post but before the second post.
<?php <-----------ADD THIS SECTION
$postnum = 1;
$addmyhtml = 1;
?> <-----------
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
The bottom line there is for reference.Next, add this:
<?php if ($postnum == $addmyhtml) {<——-for reference
echo 'ADD YOUR CONTENT HERE';
} ?>
<?php $addmyhtml++; ?>
<?php endwhile; else: ?>If you want it after the second post, make addmyhtml=2
That help at all ?
Ok i will test it now.
I wrote if this is ok.Well, where i should add this php that you wrote,
if you could check , this is my page http://www.guistyles.com
i would like to add after first post the post that is at low of this page, support linksin which php file i should add this , in index.php ?
Yes, it most likely goes in
index.php.Additional info:Template_Hierarchy
well when i add this to index.php i try in several places it demage the page, show that this is error 🙁
probably i don’t know where to add this
Podz has you putting in two chunks of code there, one before the
<?php if (have_posts()) : ...code and the other chunk goes after<?php if (have_posts()) : ...If you can’t figure it out you may have to post your
index.phpat http://pastebin.com/ and report back that link so we can look at the problem.Ok it is here :
ok
<?php
$postnum = 1;
$addmyhtml = 1;
?><?php if (have_posts()) : ?>
<?php if ($postnum == $addmyhtml) {
echo ‘ADD YOUR CONTENT HERE’;
} ?>
<?php $addmyhtml=2; ?>
<?php endwhile; else: ?><?php while (have_posts()) : the_post(); ?>
<div class=”post”>
and
Parse error: parse error, unexpected T_ENDWHILE in /homeg/informatyka/2001/ID/s/slabosz/public_html/wordpress/wp-content/themes/aquasoft/index.php on line 50line 50 is :
<?php endwhile; else: ?>
1. Obviously you didn’t read carefully what Podz posted. In between the two code snippet there should be the rest of The_Loop.
2. MichaelH asked you to post the code at http://pastebin.com – se that we can go there and edit it to help you.Try this: http://pastebin.com/466666
Not guaranted but it might work.
Where it says: ADD YOUR CONTENT HERE – write your text.Well it work , but not when i add my content :
<div class=”heading” Sponsored links </div>
<small>December 15rd, 2005 , 3:27 pmPass 2 minute ago
</small>google ads
Got this :
Parse error: parse error, unexpected ‘<‘ in /homeg/informatyka/2001/ID/s/slabosz/public_html/wordpress/wp-content/themes/aquasoft/index.php on line 93
hmm and what no response, i get this error with adding my contest , maybe you could say why it won’t start and i get this parse error, when i use echo test it works
Well, some people are in a totally different time zone at the other end of the world… If it works properly just echoing a test text – it means there is something wrong with the code you put in.
The topic ‘Add something after first post’ is closed to new replies.