Reputation: 21
<?php
function ash_now_big(){
$debut = 0; //The first article to be displayed
query_posts('cat=45&showposts=1');
while(have_posts()) : the_post();//while loop
$myposts = get_posts('numberposts=-1&offset=$debut');
if (has_post_thumbnail( $post->ID ) ):
$output .= $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
$output .=' <a href="'. the_permalink().'"><img src="'. $image[0] .'" style="width:100%"></a>';
endif; // end of if
endwhile; //end of while
return $output;
}
add_shortcode("ash_now_big", "ash_now_big");//creating shortcode
This shortcode when used just displays [ash_now_big] what could be the problem
Upvotes: 1
Views: 58
Reputation:
Where have you put this code in your project? Do you have any plugin or do you just want to put it in function file?
Please put below code in your theme functions.php file:
function ash_now_big(){
$debut = 0; //The first article to be displayed
query_posts('cat=1&showposts=1');
while(have_posts()) : the_post();//while loop
$myposts = get_posts('numberposts=-1&offset=$debut');
if (has_post_thumbnail( $post->ID ) ):
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
$output .=' <a href="'. get_the_permalink().'"><img src="'. $image[0] .'" style="width:100%"></a>';
endif; // end of if
endwhile; //end of while
return $output;
}
add_shortcode("ash_now_big", "ash_now_big");//creating shortcode
Upvotes: 1