user5854440 user5854440 - 1 year ago 75
PHP Question

Wordpress functions not working in custom theme

So I'm super new to Wordpress. I set up a Wordpress local server on MAMP yesterday and I'm trying to build my own theme currently. Trouble is, whenever I try to do

the loop
, I'm not getting any content. my code works if I just use php, but the problem is custom Wordpress functions aren't usable (i.e.

A couple other posts have suggested requiring
, but that hasn't worked either. Here's my code:


define('WP_USE_THEMES', false);

if(have_posts()) :
echo 'testing'

else :
echo 'testing'


Nothing currently displays on my screen.

is located here:
wordpress -> wp-blog-header.php

My custom theme is located here:
wordpress -> wp-content -> themes -> firstTheme -> index.php

All tips are appreciated.

Answer Source

Well, you're writing PHP and your code contains

if(have_posts()) :
    echo 'testing'
else : 
    echo 'testing'

I'm not sure how can this be valid in PHP. I'd expect

    echo 'testing';
    echo 'testing';

See also if and else syntax in PHP.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download