Tag All,
habe gerade ein großes Problem mit Wordpress und sogenanntem "Text Formatter" den ich für bessere Formatierung eingebunden habe (nicht selber geschrieben), seit dem funktioniert aber mein anderes Code "Shortcode" nicht mehr.
Da ich noch nicht wirklich gut in PHP bin, finde ich das Problem nicht, habe schon viele Sachen probiert :'(
Hier der Text Formatter was neu dazu kam:
PHP
function theme_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}
return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'theme_formatter', 99);
Alles anzeigen
Und hier der Code der für eine Bilder-Slideshow ist und der nicht mehr richtig angezeigt wird:
PHP
function mytheme_custom_slideshow($atts,$content = null) {
global $post;
extract(shortcode_atts(array(
'number' => $number,
'width' => $width,
'height' => $height
), $atts));
$img_width = ($width) ? $width : 600;
$img_height = ($height) ? $height : 300;
$out = '<div id="custom_nivoslider" style="width:'.$img_width.'px;height:'.$img_height.'px;">';
query_posts(array( 'post_type' => 'portfolio','showposts' => $number,'orderby'=>'rand'));
if (have_posts()) :
while (have_posts() ) : the_post();
$pf_link = get_post_meta($post->ID, '_portfolio_link', true );
$pf_url = get_post_meta($post->ID, '_portfolio_url', true );
$pf_preview = ($pf_link) ? $pf_link : thumb_url();
$out .= '<a href="'.$pf_preview.'" rel="prettyPhoto[custom_slideshow]">'."\n";
$out .= '<img src="'.get_bloginfo('template_directory').'/timthumb.php?src='.thumb_url().'&h='.$img_height.'&w='.$img_width.'&zc=1" title="<h5><a href='.get_permalink().'>'.get_the_title().'</a></h5>" /></a>'."\n";
endwhile;endif;
wp_reset_query();
$out .= '</div><style type="text/css">.nivo-caption {width:"'.$img_width.'"px};</style>';
return $out;
}
add_shortcode('mytheme_slideshow', 'mytheme_custom_slideshow');
Alles anzeigen
Hoffe ihr könnt mir helfen, wäre Euch sehr dankbar. Wenn keine direkte Hilfe, wenigstens ein Tipp :)
Gruß reebo