creating a my_recent_posts shortcode
-
Hey guys,
for some reason I can’t get sanitize title to work. I’m using the following code to create a shortcode in Shortcode Exec PHP Administration. When I echo the_title() it shows “Test Post”. When I echo sanitize_title( the_title() )it shows the same thing “Test Post”. If I echo sanitize_title( ‘Test Post’ ) it shows test-post. As far as I understand it its ok to pass the_title() to sanitize_title() but for whatever reason it doesn’t seem to be working. Any help?
*also am I in the right place here? I’ve only ever posted to specific plugin support*
Thanks,
Dan
code:
extract(shortcode_atts(array('arg' => 'default'), $atts)); $post_author = do_shortcode( '[post_author]' ); $user = get_user_by('login', $post_author); query_posts('author='.$user->ID.'&order=ASC'); while ( have_posts() ) : the_post(); echo ' <li>'; echo sanitize_title( the_title()); echo '<a href="http://www.businessnetworkingorangecounty.com/'; sanitize_title( the_title() ); echo '">'; the_title(); echo ''; echo '</li> '; endwhile;[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]
The topic ‘creating a my_recent_posts shortcode’ is closed to new replies.