• 0

Wordpress 3 small help


Question

after updating to WP3 my theme seems to have a weird problem <?php the_content(); ?> & <?php the_author_meta('description'); ?> is not grabbing any data from WP everything else is working except for those and this is just in my theme only .

this is the custom page i`m using

&lt;?php
/*
 Template Name: Custom
 */
?&gt;
&lt;?php get_header(); ?&gt;
&lt;?php if(is_page('home')){ ?&gt;
&lt;h2 id="tagline" class="intro"&gt;
    &lt;?php the_content(); ?&gt;
&lt;/h2&gt;

&lt;?php $services=get_post_meta($post-&gt;ID,'my_services',true); ?&gt;
&lt;div id="services" class="home_intro"&gt;
    &lt;?php echo $services; ?&gt;
&lt;/div&gt;

&lt;?php $action=get_post_meta($post-&gt;ID,'action_buttons',true); ?&gt;
&lt;div id="action_buttons" class="home_intro"&gt;
    &lt;?php echo $action; ?&gt;
&lt;/div&gt;

&lt;div id="blog_latest" class="home_intro"&gt;
    &lt;h3&gt;blog&lt;/h3&gt;
    &lt;ul&gt;
        &lt;?php
        $postslist=get_posts('numberposts=3&amp;order=DES&amp;orderby=date');
        foreach ($postslist as $post):
            setup_postdata($post);

        ?&gt;
        &lt;li&gt;
            &lt;p&gt;
                &lt;a href="&lt;?php the_permalink();?&gt;"&gt;
                    &lt;?php the_title(); ?&gt;
                &lt;/a&gt;
                &lt;em&gt;
                    &lt;?php the_date(); ?&gt;
                &lt;/em&gt;
            &lt;/p&gt;
        &lt;/li&gt;
        &lt;?php endforeach; ?&gt;
    &lt;/ul&gt;
&lt;/div&gt;

&lt;?php } else{ ?&gt;
&lt;?php if(is_page('about')){ ?&gt;
&lt;h2&gt;
    &lt;?php wp_title(''); ?&gt;
&lt;/h2&gt;
&lt;div id="about"&gt;
    &lt;?php the_author_meta('description'); ?&gt;
&lt;/div&gt;
&lt;?php $status=get_post_meta($post-&gt;ID,'status',true); if($status): ?&gt;
&lt;p id="status"&gt;
    &lt;a href="../contact/" title="" class="available"&gt;
        &lt;?php echo $status; ?&gt;
    &lt;/a&gt;
&lt;/p&gt;
&lt;?php endif; ?&gt;

&lt;div id="about_sidebar"&gt;
    &lt;?php $skills=get_post_meta($post-&gt;ID,'skills',true); ?&gt;
    &lt;div id="skills"&gt;
        &lt;?php echo $skills; ?&gt;
    &lt;/div&gt;

    &lt;?php $goodies=get_post_meta($post-&gt;ID,'goodies',true); ?&gt;
    &lt;div id="goodies"&gt;
        &lt;?php echo $goodies; ?&gt;
    &lt;/div&gt;

&lt;/div&gt;
&lt;?php $resume=get_post_meta($post-&gt;ID,'resume',true); ?&gt;
&lt;?php echo $resume; ?&gt;
&lt;?php } else{ ?&gt;
&lt;?php if(!is_page('blog')){?&gt;
&lt;h2&gt;
    &lt;?php wp_title(''); ?&gt;
&lt;/h2&gt;
&lt;?php the_content(); ?&gt;
&lt;?php } else{ ?&gt;
&lt;h2&gt;Not Found&lt;/h2&gt;
&lt;p&gt;
    Sorry, but you are looking for something that isn't here.
&lt;/p&gt;
&lt;?php } ?&gt;
&lt;?php } ?&gt;
&lt;?php } ?&gt;
&lt;?php get_footer(); ?&gt;

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

might help if you post the entire theme so we can test it out

the problem occurs only in the pages that uses this template only so i don`t think it has anything to do with the entire theme

Link to comment
Share on other sites

  • 0

You can't grab the_content outside of the loop..

You might want to read up on the_loop (http://codex.wordpress.org/The_Loop) and the_content (http://codex.wordpress.org/Template_Tags/the_content).

For the_content:

Displays the contents of the current post. This tag must be within The_Loop.

Example

&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;
&lt;?php the_content(); ?&gt;
&lt;?php endwhile; else: ?&gt;
&lt;p&gt;&lt;?php _e('Sorry, no posts matched your criteria.'); ?&gt;&lt;/p&gt;
&lt;?php endif; ?&gt;

And if you want to use custom fields outside of the loop:

&lt;?php
global $wp_query;
$postid = $wp_query-&gt;post-&gt;ID;
echo get_post_meta($postid, 'status', true);
?&gt;

As far as the author_meta goes, are you sure that the page you're looking at, the author has a description? Common mistake to make.. No changes to author_meta have changed for 3.0.

http://codex.wordpress.org/Template_Tags/the_author_meta

The the_author_meta Template Tag displays the desired meta data for a user. If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop.
Link to comment
Share on other sites

  • 0

thanks +Cupcakes.

but what makes the same exact template is working on WP 2.9.2 and the_content with no loop & custom fields too "although they are is still working in this page" ? & the author meta yes have a description & if i`m not wrong it`s the Biographical info box in Your profile ?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.