Wordpress Code Issues

Status
Not open for further replies.

JamesH

New member
Jun 25, 2006
2,513
26
0
I'm having some retarded ass issue with some code. I'm not a coder at all, I copy and paste everything I need off the web and 99% of the time I can get it to work. But for the life of me I can't understand why this isn't working:
PHP:
<?php  if ( is_page('Shot Glasses') ) { ?>

<?php query_posts('category_name=homepage&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>

<?php } ?>

If I throw in some text before the query_posts (such as <p>Test</p>), it works all fine and dandy when I'm on the home page. However it won't post text from that category using the query_posts. What am I doing wrong?
 


Not much of a coder either but if you have an if, don't you need an else?

Code:
 <?php  if ( is_page('Shot Glasses') ) { ?>
[COLOR=Yellow][I] some category loop here.[/I]
<?php else : ?>[/COLOR]
<?php query_posts('category_name=homepage&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>

<?php } ?>
What exactly are you trying to accomplish? I think I know but I'm not sure.
 
@abhorrent: No, he doest need an else.

@JamesH: I suspect you are trying to query the wrong category. Do you really have a category called "homepage"? You have to call the category by the Name, not the URL slug.
 
@JamesH: I suspect you are trying to query the wrong category. Do you really have a category called "homepage"? You have to call the category by the Name, not the URL slug.

Yup, I'm 100% sure that the category name issue isn't the problem. I tried with several categories and none of them worked, along with plugging in the URL slug and category number just to see if that would work. No luck...
 
Can you post the complete code or is that it?
Is this the index, and archive page or what?

Have you tried disabling plugins one by one to see if maybe there is one that's causing the problem?
 
  • Like
Reactions: JamesH
Dude, I fucking love you. +rep

It was some stupid ass plug-in that didn't work to begin with. Thanks man.
 
That's usually the first thing I check. A lot of (most) plug-ins seem to override and just take over everything.

Glad you got it fixed.
 
Status
Not open for further replies.