Forums

The loop - getting rid of the paragraph (2 posts)

  1. Nowayback
    Member
    Posted 1 year ago #

    Hi folks!

    Currently I am working on a website that runs on WordPress.

    What I have so far:
    - A working shadowbox plugin for showing pictures
    - Posts are split into two categories, blog and showcase.
    - I edited the loop to post the posts in the categorie blog on the frontpage and posts in the categorie showcase to the showcase page.

    The loop on the showcase page looks like this:

    <?php the_post() ?>
    	<?php query_posts('category_name=Showcase'); ?>
    		<?php while (have_posts()) : the_post(); ?>
    
    		<?php the_content() ?> 
    
    	<?php wp_tag_cloud(''); ?>
    <?php endwhile;?>

    I know that the code <?php the_content() ?> is the part that actually shows the post so to say.

    And now my problem;
    The only thing that's going to be posted in the categorie showcase is a link to a picture. So I thought, I put a <a href=" (etc) tag around it so that you only have to post a link and the code wil make a shadowbox of it.

    BUT, wordpress automaticly puts a paragraph around a post, how do I delete that?

    AND, it first links to the website its self, so a link posted looks like:
    http://www.mysite.com/wordpress<p>www.picture.com/picture.jpg</p&gt;

    Does anyone know how to solve this?

  2. doodlebee
    Member
    Posted 1 year ago #

    There's several solutions. Your simplest would be to add classes to your category layout.

    <?php the_post() ?>
    	<?php query_posts('category_name=Showcase'); ?>
    		<?php while (have_posts()) : the_post(); ?>
                    <div class="catlink">
    		<?php the_content() ?>
                    </div>
    	<?php wp_tag_cloud(''); ?>
    <?php endwhile;?>

    then apply the shadowbox to the div.catlink p class, or div.catlink p a to target the link. If you mess with the_content and remove the filter from it (that's what you're looking to do: remove the wpautop filter) it requires some PHP coding so you don't remove the filter from your blog posts as well. CSS would be your best bet.

    Alternatively, you could use echo get_the_content() instead of the_content. That pulls the content without adding any filters at all. but again, you'd have to be sure to place it only in the category template area where you want this to happen, otherwise your blog posts and Pages would be affected by this, as well.

Topic Closed

This topic has been closed to new replies.

About this Topic