Wordpress PHP Help Please. Anyone?

3 replies
  • WEB DESIGN
  • |
I have this code below. I wanted to display custom posts I created into a page. :confused:

<div id="primary">
<div id="content" class="clearfix">
<?php
$args = array( 'post_type' => 'Business', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

echo '<div class="businessentry-content">';
the_title();
the_content();
echo '</div>';
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->

I wanted to add a link to the_title(); but when i add the <a> tag the page will turn to a blank page. What should be the correct code for it?
I also wanted to grab the images uploaded on each custom posts and display as thumbnails on the left side of the content. Is this possible? I really need to fix this. Thanks!
#php #wordpress
  • Profile picture of the author RobinInTexas
    I can't tell if you are trying to create a theme from scratch or edit an existing theme.

    In any event the code is probably going to get too big for the forum to present it properly, please use Pastebin.com - #1 paste tool since 2002! and paste the whole php file.

    A blank page is a good indication of a php error, look in your server error log.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[9213951].message }}
  • Profile picture of the author fulfilledlife
    zton82005

    Try the following code:

    <div id="primary">
    <div id="content" class="clearfix">
    <?php
    $args = array( 'post_type' => 'Business', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    ?>

    <div class="businessentry-content">
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?>
    </a>

    <?php
    the_content();
    echo '</div>';
    endwhile;
    ?>
    </div><!-- #content -->
    </div><!-- #primary -->
    Signature

    Try not to become a man of success, but rather try to become a man of value - Albert Einstein

    {{ DiscussionBoard.errors[9214523].message }}
    • Profile picture of the author zton82005
      OMG your code worked! Thank you very much fulfilledlife!
      Actually i am creating a new page template for the custom posts type and display all business listings on the page using that template.

      One last question, how can i grab and display the uploaded image (business logo) on each custom posts? I used custom fields for image upload and i want them to show up as thumbs.

      Can you show me what code to insert?:confused:

      Thanks again!
      {{ DiscussionBoard.errors[9214701].message }}

Trending Topics