Quantcast
Viewing latest article 6
Browse Latest Browse All 8

Playing with WordPress plugins – Part I

Quite a while back, I wanted to make a quiz site with questions about PHP, and as I’m still into learning more about WordPress, the only logical thing to do is to develop a plugin that will make WordPress into the perfect CMS for this project.

At this moment, there are 5,855 plugins in the WordPress plugin directory. If so many other people have done it, surely it can’t be too hard, right? But I spent countless hours reading the documentation months ago and never had anything to show for it….

Well, this time I’m going agile. I wrote a post asking “What is 2 + 2?”, added a custom field called “correct” with the value 4, and now have the code to make that answer appear underneath the blog entry. It took me a while to figure out that I needed to pass $content to my function to keep the post from disappearing, but it looks like I’m on my way.


add_action( 'the_content', 'the_pop_quiz' );
function the_pop_quiz($content) {
echo $content;
$flif_pid = get_the_ID();
$pop_quiz_answer = get_post_meta( $flif_pid, 'correct', true );
echo $pop_quiz_answer;
}


Viewing latest article 6
Browse Latest Browse All 8

Trending Articles