2016-06-14 4 views
1

Ich habe die Standard-Wordpress-Galerie mit einem benutzerdefinierten Plugin mit BxSlider ersetzt.Filter hinzufügen Wordpress (Shortcode funktioniert nicht in rss)

Das Plugin funktioniert wie es sollte am Frontend.

<?php 
/* 
Plugin Name: Weemsel Gallerij 
Plugin URI: https://www.hetweemsel.nl 
Description: Weemsel Gallerij met Facebook instant articles support 
Version: 1.0 
Author: Het Weemsel 
Author URI: https://www.hetweemsel.nl 
*/ 

remove_shortcode('gallery'); 
add_shortcode('gallery', 'parse_gallery_shortcode'); 

wp_register_style('bxslider-css', plugins_url() . '/weemsel-gallerij/assets/css/jquery.bxslider.css', false, null); 
wp_enqueue_style('bxslider-css'); 

wp_register_script('bxslider-js', plugins_url() . '/weemsel-gallerij/assets/js/jquery.bxslider.min.js', false, null, true); 
wp_enqueue_script('bxslider-js'); 

wp_register_script('setup-js', plugins_url() . '/weemsel-gallerij/assets/js/bxsetup.js', false, null, true); 
wp_enqueue_script('setup-js'); 

function parse_gallery_shortcode($args) { 

    global $post; 

    if (! empty($atts['ids'])) { 
     // 'ids' is explicitly ordered, unless you specify otherwise. 
     if (empty($atts['orderby'])) 
      $atts['orderby'] = 'post__in'; 
     $atts['include'] = $atts['ids']; 
    } 

    extract(shortcode_atts(array(
     'orderby' => 'menu_order ASC, ID ASC', 
     'include' => '', 
     'id' => $post->ID, 
     'itemtag' => 'dl', 
     'icontag' => 'dt', 
     'captiontag' => 'dd', 
     'columns' => 3, 
     'size' => 'full', 
     'link' => 'file' 
    ), $atts)); 


    $args = array(
     'post_type' => 'attachment', 
     'post_status' => 'inherit', 
     'post_mime_type' => 'image', 
     'orderby' => $orderby 
    ); 

    if (!empty($include)) 
     $args['include'] = $include; 
    else { 
     $args['post_parent'] = $id; 
     $args['numberposts'] = -1; 
    } 

    $images = get_posts($args); 
    ?> 
    <?php 
    ob_start(); 

     echo '<ul class="bxslider">'; 
      foreach ($images as $image) { 
        echo '<li><figure><img src="'; 
        echo wp_get_attachment_url($image->ID, $size); 
        echo '" /></figure></li>'; 
       } 
     echo '</ul>'; 




     echo '<div id="bx-pager">'; 

      $i = 0; 

      foreach ($images as $image) { 
        echo '<a data-slide-index="'; 
        echo $i++; 
        echo $item[number]; 
        echo '" href=""><figure><img src="'; 
         echo wp_get_attachment_image_url($image->ID, $size); 
        echo '" /></figure></a>';   
      } 
     echo '</div>'; 


    $content = ob_get_contents(); 
    ob_end_clean(); 

    return $content; 

} 

add_filter('the_excerpt','do_shortcode', 10, 100); 
add_filter('the_content','do_shortcode', 10, 100); 
add_filter('the_excerpt_rss','do_shortcode', 10, 100); 
add_filter('the_content_rss','do_shortcode', 10, 100); 
?> 

Irgendwie, wenn das Ergebnis in RSS die add_filter-Funktion ist wirklich seltsam nicht die html noch die richtigen Links ausgibt. Der RSS-Feed ist ein personalisiertes Feed

<?php 
/** 
* Template Name: Zakelijke feed 
*/ 
$postCount = 5; // The number of posts to show in the feed 
$posts = query_posts('showposts=' . $postCount .'&cat=52'); 
header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true); 
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; 
?> 
<rss version="2.0" 
     xmlns:content="http://purl.org/rss/1.0/modules/content/" 
     xmlns:wfw="http://wellformedweb.org/CommentAPI/" 
     xmlns:dc="http://purl.org/dc/elements/1.1/" 
     xmlns:atom="http://www.w3.org/2005/Atom" 
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
     xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 
     <?php do_action('rss2_ns'); ?>> 
<channel> 
     <title><?php bloginfo_rss('name'); ?> - Feed</title> 
     <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> 
     <link><?php bloginfo_rss('url') ?></link> 
     <description><?php bloginfo_rss('description') ?></description> 
     <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> 
     <sy:updatePeriod><?php echo apply_filters('rss_update_period', 'hourly'); ?></sy:updatePeriod> 
     <sy:updateFrequency><?php echo apply_filters('rss_update_frequency', '1'); ?></sy:updateFrequency> 
     <?php do_action('rss2_head'); ?> 
     <?php while(have_posts()) : the_post(); ?> 
       <item> 
         <title><?php the_title_rss(); ?></title> 
         <link><?php the_permalink_rss(); ?></link> 
         <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> 
         <dc:creator><?php the_author(); ?></dc:creator> 
         <guid isPermaLink="false"><?php the_guid(); ?></guid> 
         <description xml:space="preserve"><![CDATA[ <?php the_post_thumbnail('medium'); ?> ]]><![CDATA[ <?php the_excerpt(); ?> ]]></description> 
         <content:encoded xml:space="preserve"><![CDATA[ <?php the_post_thumbnail(); ?> ]]><![CDATA[ <?php the_content_rss() ?> ]]></content:encoded> 
         <?php rss_enclosure(); ?> 
         <?php do_action('rss2_item'); ?> 
       </item> 
     <?php endwhile; ?> 
</channel> 
</rss> 

Der Ausgang ich erhalte wirklich seltsam und kann unter folgender Adresse zu sehen: https://woerden.tv/zakelijk/feed/zakelijk

https://woerden.tv"><figure><img src= [3] https://woerden.tv"><figure><img src= [4] https://woerden.tv"><figure><img src= [5] https://woerden.tv"><figure><img src= [6] https://woerden.tv"><figure><img src= 

Wer kann mir sagen, was falsch läuft ?

Mit besten Grüßen, Dylan

+0

Die RSS-Vorlage wird mit einem veraltete Funktion https://codex.wordpress.org/Template_Tags/the_content_rss Ich würde in das erste –

+0

Danke für Ihren Beitrag suchen. Ich habe es mit dem_content_feed behoben. –

+0

Froh, es zu hören, werde ich es als eine richtige Antwort setzen –

Antwort

Verwandte Themen