Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Allow posts to show HTML WordPress

  • SOLVED

Hello, I am using the 'Jquery Accordion' (http://www.jeffikus.com/downloads/wordpress-jquery-accordion-plugin/) plugin in the sidebar of a site to show posts you can see here:

http://www.willpowerproductions.co.uk/

However it does not allow me to show html here only standard text, how can I make it show exactly whats in the post and output html?

For example I put youtube embed codes in the post but it doesn't show the youtube vid in the sidebar.

Here is the code for the widget:

<?php
/*
Plugin Name: Jquery Accordion
Plugin URI: http://www.jeffikus.com/downloads/wordpress-jquery-accordion-plugin/
Description: A jquery accordion of the latest posts in a specific category
Version: 0.1
Author: Jeffikus
Author URI: http://jeffikus.com
*/

/* Copyright 2009 Jeffikus (email : pearce DOT jp [at] gmail DOT com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

if (!class_exists("JqueryAccordion")) {
class JqueryAccordion {
/*
* Constructor
*/
function JqueryAccordion() {

}

/*
* Function to load the required jquery libraries
* jquery
* UI
* accordion
*/
function load_jquery() {
//Load required jquery libraries and stylesheets and perform accordion functionality
$siteURL = get_bloginfo( 'url' );
echo '<link type="text/css" href="'.$siteURL.'/wp-content/plugins/jquery-accordion/jquery/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="'.$siteURL.'/wp-content/plugins/jquery-accordion/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="'.$siteURL.'/wp-content/plugins/jquery-accordion/jquery/ui/ui.core.js"></script>
<script type="text/javascript" src="'.$siteURL.'/wp-content/plugins/jquery-accordion/jquery/ui/ui.accordion.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#accordion").accordion({active: false, alwaysOpen: false, autoheight: false});
});
</script>
';
}

/*
* Function to load the accordion when called using the shortcode:
* [jqueryaccordion posts="3" category="Featured"]
*/
function jqueryaccordion_func($atts) {
//set defaults
extract(shortcode_atts(array(
'posts' => '3',
'category' => 'Featured',
), $atts));
//set query arguments
$argsAccordion=array(
'posts_per_page'=>$atts['posts'],
'category_name'=>$atts['category']
);
//query the posts
$postResults = new WP_Query($argsAccordion);
//BEGIN - results layout
$result = '<div id="accordion">';
//loop through the posts
while($postResults->have_posts()) : $postResults->the_post();

$result .= '<h3><a href="#">';
$result .= get_the_title($postResults->ID);
$result .= '</a></h3>';
$result .= '<div><p>';
$result .= get_the_excerpt();
$result .= '</p></div>';

endwhile;

$result .= '</div>';
//END - results layout

//return results
return $result;

}




}
} //End Class JqueryAccordion

if (class_exists("JqueryAccordion")) {
$jqueryAccordion = new JqueryAccordion();
}

//Actions and Filters
if (isset($jqueryAccordion)) {
//Actions
//hookup the function to load jquery in the header
add_action('wp_head', array(&$jqueryAccordion, 'load_jquery'), 1);
//assign function to a shortcode
add_shortcode('jqueryaccordion', array(&$jqueryAccordion, 'jqueryaccordion_func'));
//Filters
}

?>

Answers (5)

2011-09-06

Navjot Singh answers:

Try replacing


$result .= get_the_excerpt();


with


$result .= get_the_content();


in the plugin file. Wordpress strips all HTML from the excerpt so you will need to display full content for which this change is necessary.

2011-09-06

Julio Potier answers:

Hello

You only have to fill a real excerpt in your posts because WordPress sanitize the content into the excerpt if you leave it blank on publication.

See you

2011-09-06

Hardeep Singh answers:

Navjot is faster than me :)

Just to add to his answer, this will display the complete content of the post.
So create content accordingly.

Thanks!!!

2011-09-06

John Cotton answers:

By default, WordPress strips HTML from content when it automatically creates an excerpt (ie if you leave that box blank).

So either change get_the_excerpt to get_the_content or, if you want a shorter version for your accordian, put an explicit excerpt in the box on the post edit page.

2011-09-07

Benjamin Goldberg answers:

I don't know if this is will work for you but I posted a function which allows for some tags in excerpts as long as the tag is properly closed, which could be a problem with excerpts because a closing tag might get cut off from a starting tag. If you want to try it you should probably copy the get_the_excerpt function and the safetags function from my functions.txt file nto your functions.php file. More [[LINK href="http://bnmngcomputing.wordpress.com/2011/09/05/an-improvement-and-another-use-for-the-safetags-function/"]]here[[/LINK]]