WordPress.org

Ready to get started?Download WordPress

Forums

Problem with custom post types and loops (2 posts)

  1. Lado Lomidze
    Member
    Posted 2 years ago #

    Hello guys!

    I'm using wordpress latest, 3.1.3 version.
    With wordpress More Types plugin I've created Events post type.

    I added some basic information about event such as title and short description.

    Then in my sidebar.php I included upcoming-events.php file like this
    <?php get_template_part('upcoming', 'events'); ?>
    and in that file I have this code:

    <?php $events = new WP_Query( 'post_type=event&showposts=5' ); ?>
    <div class="widget widget_upcoming_events" id="upcoming_events">
        <h2>Upcoming Events</h2>
        <?php if( $events->have_posts()) :  while( $events->have_posts() ) : $events->the_post(); ?>
    		<h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
            <?php the_content('Read More →'); ?>
        <?php endwhile; ?>
        <?php else: ?>
        No Upcoming Events
        <?php endif; ?>
    </div>

    On home page it shows me just like I want it. In Editor where I "split" the event description, the "Read More" tag appears there.

    Take a Look at this screenshot - http://img18.imageshack.us/img18/6321/screen1fp.png

    But when I go to other pages, such as Archive, Category, Single and etc, the "more tag" in upcoming events doesn't work. It gives me full text, instead of teaser. Look at this screenshot - http://img9.imageshack.us/img9/5061/screen2byj.png

    So, can anyone help me to solve this problem? All I want to do, is that "more tag" work on every page normally. : )

  2. Lado Lomidze
    Member
    Posted 2 years ago #

    Well, funny thing. I've searched the topic about same problem and i found this post http://wordpress.org/support/topic/how-do-i-use-the_content-and-the-loop-tags-on-sub-pages?replies=9

    After trying several things with this code, I finally get the result, what I expected.
    I just added this code
    <?php global $more; $more = false; ?>
    after this line
    <?php if( $events->have_posts()) : while( $events->have_posts() ) : $events->the_post(); ?>
    and that's it : )

Topic Closed

This topic has been closed to new replies.

About this Topic