Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGhost Nose
2,516 PointsAdd a new shortcode named my_plugin_shortcode_name based on my_plugin_shortcode.
<?php
function my_plugin_shortcode( $atts, $content = null ){
global $post;
extract(shortcode_atts( array( 'num_courses' => '4' ) , $atts) );
ob_start();
require('inc/front-end.php');
$content= ob_get_clean();
}
add_shortcode( 'my_plugin', 'my_plugin_shortcode' );
?>
I'm getting this response when I check the code: Bummer! The shortcode name should be passed as the first argument to add_shortcode.
Semi-frustrated that this code isn't passing since it's relatively a semantics error.
Can someone help me out.
Thanks in advance :)
4 Answers
Zac Gordon
Treehouse Guest TeacherIt looks like the name "my_plugin" does not line up with the name said to use in the prompt.
valeriuv
20,999 PointsDoes your function return anything? (hint)
Ghost Nose
2,516 PointsThank you for pointing that out! Unfortunately that still didn't allow me to pass the assignment. The error is truly in the add_shortcode() function
Ghost Nose
2,516 PointsAwesome I don't know what I was thinking this is the fix, thanks zac
add_shortcode( 'my_plugin_shortcode_name', 'my_plugin_shortcode' );
Patrick Munemo
14,892 PointsHere is your answer bro,
add_shortcode( 'my_plugin_shortcode_name', 'my_plugin_shortcode' );