I am totally new here and beginningfrom scratch coding!
I am currently working on this website and especially the right sidebar on the home page.
As you can see, it shows News and Articles and under each of these, the name of the posts and its dates. What I want to add is a third division called Broadsight Magazine, which I achieved to do but it shows the full posts!
How could I just get the name and the date?
I used the following code:
<h3 class=”blog-header”>magazine”><?php _e(“<!–:en–>Broadsight Magazine<!–:–><!–:th–>แมกกาซีน<!–:–>”); ?></h3>
<?php $magazine = array( ‘post_type’ => ‘magazine’, ‘posts_per_page’ => ‘3’, ‘order’ => ‘DESC’, ‘orderby’=> ‘ID’ ); $loop = new WP_Query( $magazine ); while ( $loop->have_posts() ) : $loop->the_post(); ?>
<h4>“><?php the_title(); ?></h4>
<?php the_content( __( ‘Read the Rest →’, ‘broadgate’ ) ); ?>
<?php endwhile; ?>
Many thanks for your help!
<h4><?php the_title(); ?></h4> <p><?php the_date(); ?></p> <?php get_the_ID(); ?> <a href="<?php $post_id=get_the_ID(); echo get_permalink($post_id); ?>"> Read the rest </p>
<h4>”><?php the_title(); ?></h4>
<?php the_content( __( ‘Read the Rest →’, ‘broadgate’ ) ); ?>`
From the source code of your previous 2 sidebar sections, which you are trying to replicate, it *seems that this is kind of a hack. It requires putting a read more quicktag at the topmost of each post content.
The right way is to not use
the_content()as per @souravb, but since it’s in the loop,
So this part
<?php the_content( __( 'Read the Rest →', 'broadgate' ) ); ?>
<p><a href="<?php the_permalink(); ?>"><?php _e( 'Read the Rest →', 'broadgate' ); ?></a></p>
This won’t require you to put in more quicktag at the topmost of each post, which is a wrong way of using more tag.
Also, don’t forget
Thank you very much for your answers both of you!
You are right! I need to add a quicktag on each post if I keep the same code!
Many thanks!!! I least it doesn’t look messy now!
Sorry. This is the correct code.
<h4><?php the_title(); ?></h4> <p><?php the_date(); ?></p> <a href="<?php $post_id=get_the_ID(); echo get_permalink($post_id); ?>"> Read the rest</a>
- The topic ‘Sidebar showing full posts’ is closed to new replies.