Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

sescpapa on "random post instead of default text - issues"

$
0
0

Hi everybody.
I've just signed up here at wordpress.org and I'm pretty new to it.
Anyway, I'm working on a website which is based on this cool template by HTML5UP.
It took me a few days till I got it appearing as it should, once moved to the "themes" folder of my wordpress installation, but now it looks pretty ok, except for the icons inside the ligh-teal frame halway down the page, but that's ok for now.
Today, I've begun modifying the theme and one of the most important things I'd like to do is to replace the text under the welcoming header and instead make so that a random post appears.
For that, I tried this - which I copied from some similar thread:

<p>
<?php $posts = get_posts('orderby=rand&numberposts=1');
foreach($posts as $post) { ?>
<li>
<!--
a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"
-->
<?php the_title(); ?></a>
</li>
<?php } ?>
</p>

And it worked! I commented out what I anticipated as a link because I didn't want it to be one.
I've still got a couple of problems, though.
1. I get an ugly dot at the beginning of my post.
2. I would prefer to show the content instead of the title of my post.
3. This whole block of code is within a <div class="inner">, which has a really cool style assigned to it by the original css-stylesheet of the template, but I can't get my post to obey that css.
4. I'd like this random post to be followed by another parameter of the same post within another tag. For example, if the content of my random post appears within this p-tag, I want it followed by the title of the same random post, but within a footer-tag.
Answer any of my four questions, if you don't have enough time to deal with all of them. Any kind of help is appreciated. Thanks in advance.


Viewing all articles
Browse latest Browse all 8245

Trending Articles