Here my code in case anyone have time to have a look at it
this one is displaying the last post twice on the homepage at the top and bottom even thou i place the [shortcode] inside a div.
PHP Code:
<?php
function wptuts_working_shortcode($atts, $content=null){?>
<div class="left home_bot_box"><!-- START LOOP TO DISPLAY LATEST POST ONLY-->
<h2>latest</h2>
<?php
global $more; // Declare global $more (before the loop).
$more = 0; // Set (inside the loop) to display content above the more tag.
?>
<?php
// set while loop to display only post of category latest-news and one post only per page
query_posts('category_name=latest-news&posts_per_page=1');
?>
<?php while (have_posts()) : the_post(); ?>
<p><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></p>
<p><?php the_content(__('more…')); ?></p>
</div> <!-- END LOOP FOR POST ONLY-->
<?php endwhile;
?>
<?php }
add_shortcode('working', 'wptuts_working_shortcode');
?>
and this this one I cannot get it to display the the more button even thou I placed the (<!--more-->) to cut off the text and show the more link.
PHP Code:
<?php
function wptuts_recentpost($atts, $content=null){
global $more; // Declare global $more (before the loop).
$more = 0; // Set (inside the loop) to display content above the more tag.
$getpost = get_posts( array('number' => 1) );
$getpost = $getpost[0];
$return = $getpost->post_title . "<br />" . $getpost->post_content . "…";
$return = $getpost->post_title . "<br />" . apply_filters('the_content',$getpost->post_content) . "…";
return $return;
}
add_shortcode('newestpost', 'wptuts_recentpost');
?>
Bookmarks