Integrating MantisBT with WordPress

Recently I mentioned how I was integrating MantisBT with my blog. Well, I thought I’d release the code for anybody else to use and tinker with.


function show_mantis($paras="",$content="") {
    global $wpdb;
    // Get the ID for the current project
    $project_id=$wpdb->get_var($wpdb->prepare("SELECT id FROM mantis_project_table WHERE name = '".$content."' "));
    // Loop around twice, loading specific variables for each loop
    while ($loop<3) {
        if ($loop==1) {
            $category=" = 'Bug'";
            $title="Known Bugs";
        } else {
            $category="( = 'Enhancement' OR = 'Maintenance')";
            $title="Planned Enhancements";
        // Build query to look for Mantis information    
        $mantis=$wpdb->get_results("SELECT AS 'ID', summary AS 'Description' FROM mantis_bug_table a, mantis_category_table b WHERE a.project_id = ".$project_id." AND ".$category." AND a.category_id = AND a.status <> 80 AND a.status <> 90 ORDER BY");
        // Output heading 
        // Loop through and output results
        if ($mantis) {
            $output.="<p><a href="".$project_id."" target="_blank">View the roadmap</a> for ".$content."</p>";            
            foreach ($mantis as $mantis_data) {
                $output.="<li>".$desc." [<a href="".$id."" target="_blank">View</a>]</li>n";
        } else {
            if ($loop==1) {
                $output.="<p>No bugs are currently recorded.</p>";
            } else {
                $output.="<p>No enhancements are currently planned.</p>";
    return $output;


This would need adding to your functions.php file and introduced a new shortcode. Simply use [mantis]Name[/mantis] in a post or page, where Name is the project name in MantisBT.

In my code I’m displaying, separately, bugs and maintenance & enhancements (the latter two being grouped together), each with their own heading. Under each heading I also include a link to the relevant roadmap for the project.

Not surprisingly I only fetch open issues 😉

If you need any help modifying this for your own use, let me know.

One response

  1. Hi David,
    I have already integrated mantis bug tracker in my website,But i need single login.
    if user logins he should not login to bug tracker again.
    Can you please help me on this.

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: