WordPress.org

Ready to get started?Download WordPress

Forums

Code is breaking my template (6 posts)

  1. ccradmin
    Member
    Posted 1 year ago #

    I am creating a template and when i use this code

    <?php $subs = new WP_Query( array( 'post_parent' => $post->ID, 'post_type' => 'page', 'meta_key' => '_thumbnail_id' ));
    					if( $subs->have_posts() ) : while( $subs->have_posts() ) : $subs->the_post();
    						?>
    						<div class="product">
    							<? echo get_the_post_thumbnail($post->ID, 'medium'); ?>
    							<?php the_content(); ?>
    						</div>
    						<?
    					endwhile; endif; wp_reset_postdata(); ?>

    It breaks my template, "the_content()" text goes right out of the wrapper element. If I replace the code above with static text the same as whats in "the_content()" for my pages it doesn't break the template.

    Whats going on here is another thread post on a another forum i made for the same issue, use it as a reference if needed to help me fix this problem.

    http://forums.phpfreaks.com/topic/271328-p-tag-through-parent-element/

    Thanks, in Advance

  2. Jose Castaneda
    Member
    Posted 1 year ago #

    It sounds like you are having a CSS issue. It could also be that you aren't using the proper PHP opening tags.

  3. ccradmin
    Member
    Posted 1 year ago #

    its not a css problem because i have no styling on the elements atm,

    Beside on the main page of the site the styling works fine

  4. ccradmin
    Member
    Posted 1 year ago #

    From what I found it the p tag causing the text to go outside the parent element and theres no styling on it either

  5. ronangelo
    Member
    Posted 1 year ago #

    Did you check the post that you used as an example? it's curious why it should have an &nbsp; between the blahs

    It possible that the lack of styling itself is what's causing it.
    default styling could be different for static content and generated content.

    perhaps adding styling like
    overflow: hidden; for the wrapper or a word-wrap: break-word; for the <p>

    Are you creating a theme from scratch or is it a child-theme?

  6. ccradmin
    Member
    Posted 1 year ago #

    putting the word-wrap: break-word; on the <p> tag worked! thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.