Forum Replies Created

Viewing 13 replies - 46 through 58 (of 58 total)
  • Thread Starter iversoncru

    (@iversoncru)

    i think we can make the topic Resolved

    Thread Starter iversoncru

    (@iversoncru)

    Sure!! thanks again

    Thread Starter iversoncru

    (@iversoncru)

    I have figure out sth different to do the same thing.

    <article>
    	<?php
    		$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    		$temp = $wp_query;
    		$wp_query= null;
    		$wp_query = new WP_Query();
    		$args = array(
    		'posts_per_page' => 2,
    		'cat'            => 7,
    		'paged'          => $paged,
    		);
    		$wp_query->query( $args );
    		while ( $wp_query->have_posts() ) : $wp_query->the_post();
    		$post_id = get_the_ID();
    	?>
    	<?php
    		$title = get_the_title();
    		if (strlen($title) > 20) {
    			$title = substr($title, 0, 18) . '...';
    		}
    	?>
    	<h2><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a>   <?php the_time('F jS, Y') ?></h2>
    	<?php the_post_thumbnail('thumbnail');?>
    	<p>
    	<?php
    		$excerpt = get_the_excerpt();
      		echo string_limit_words($excerpt,56);
    	?>
    	</p>
    
    	<p class="read_more">Read the full post <a href="<?php the_permalink(); ?>">here</a></p>
    	<?php endwhile;
    		$page_navi = function_exists('wp_pagenavi') ? true : false ;
    		($page_navi) ? wp_pagenavi() : posts_nav_link();
    	?>
    	<?php wp_reset_postdata(); ?>
    	<?php $wp_query = null; $wp_query = $temp; ?>
    </article>

    to use the_post_thumbnail(), i had to add to my functions.php:
    add_theme_support( ‘post-thumbnails’ );

    And change the way to attach images to the posts: inside the post, click no “Set featured image”.

    I hope it helps ?? this is where i took it from… https://www.ads-software.com/support/topic/no-image-showing-in-single-post?replies=5

    Thread Starter iversoncru

    (@iversoncru)

    Thanks a lot CarletonU for your answer and your time.

    For the first price of code…

    I had already added the line:
    add_theme_support( ‘post-thumbnails’ );

    But i kept attaching the image from the Media Library. Now i do as you said, and it is working!

    Thanksssssssssssssss a looooot

    Thread Starter iversoncru

    (@iversoncru)

    i have also tried this code

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    	<?php echo $post_id = get_the_ID();?>
    	<h2><?php the_title(); ?></h2>
    	<h3><?php the_time('F jS, Y') ?></h3>
    	<?php echo wp_get_attachment_image($post_id, 'full');?>
    	<p><?php the_content(); ?></p>
    <?php endwhile; ?>
    <nav>
    	<?php previous_post_link('%link', '< Previous ' , in_same_cat, 'excluded_categories'); ?>
    	<?php next_post_link('%link', ' Next > ', in_same_cat, 'excluded_categories'); ?>
    </nav>
    Thread Starter iversoncru

    (@iversoncru)

    the images were attached to the posts from the Media Library. This means:
    I created a post and published it.
    Then i went to the Media Library and Add a new image.
    From the Media Library i clicked “attach” to attach the image to the post.

    I dont know whats happening, i was supposed to be easy o.O

    Thread Starter iversoncru

    (@iversoncru)

    oh, i see!! thanks a lot for the explanation.

    by the way, since the image is in the Media library, i attach it to the post, and everything works perfect!!

    Thankssssssssss

    Thread Starter iversoncru

    (@iversoncru)

    You are right, frizax.
    When i went to the Media Library, there is no image attached to the post, but my doubt now is:
    I could attached the image when i created the post, and i still can see it. When i preview the post, i see the image as well, but it is not in the media library.
    What is happening?

    Thread Starter iversoncru

    (@iversoncru)

    hi! thanks a lot for your answers and your time.

    frizax, I have done your suggested debugging and in the sencond one, it says ’empty’.
    But i have an image attached to the post (attached when i created the post in WP admin panel), and actually i can see it when i see the single post.
    weird :S

    Thread Starter iversoncru

    (@iversoncru)

    maybe i can use also some advice. This is the first time i try to do a blog, and im not sure if i did right using query(), for example.

    Thread Starter iversoncru

    (@iversoncru)

    keesiemeijer, thanks a lot, that works perfectly.
    Anyway, I was checking other posts, and i found this, which helped, although it does not use wp_query.

    https://www.ads-software.com/support/topic/display-the-posts-of-one-category-in-a-page-solved?replies=37

    <article>
    	<?php
    		$args = array(
    		'cat' => 7,
    		'posts_per_page' => 5,
    		'paged' => $paged
    	);
    	query_posts($args);
    	while ($wp_query->have_posts()) : $wp_query->the_post();
    	?>
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>" title="Read more"><?php the_title(); ?></a></h2>
    		<p><?php echo substr(get_the_excerpt(), 0,300); ?></p>
    	</div>
    	<?php endwhile; ?>
    	<?php if ($paged > 1) { ?>
    	<nav id="nav-posts">
    		<div><?php next_posts_link(' Previous'); ?></div>
    		<div><?php previous_posts_link('Next'); ?></div>
    	</nav>
    	<?php } else { ?>
    	<nav id="nav-posts">
    		<div><?php next_posts_link('Previous '); ?></div>
    	</nav>
    	<?php } ?>
    	<?php wp_reset_postdata(); ?>
    </article>

    thanks a lot for this post and for the answer.
    I did what you said, Stefan, and it is working perfectly and exactly how i wanted.
    Thanks a lot!!

    I would like to solve that as well, exactly the same.
    Would anyone answer? ;(

Viewing 13 replies - 46 through 58 (of 58 total)