Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Template Name: Google News Feed RSS
- */
- //$postCount = 50;
- //$posts = query_posts('category__not_in=1,46&showposts=' . $postCount);
- $args_gnr = array(
- 'post_type' => 'post',
- 'post_status' => 'publish',
- 'category__not_in' => array(1),
- 'showposts' => 50,
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'post_status' => 'publish',
- 'post_type'=>'post'
- );
- $query_gnr = new WP_Query( $args_gnr );
- header('Content-Type: '.feed_content_type('rss-http').'; charset='.get_option('blog_charset'), true);
- echo '<?xml version="1.0" encoding="UTF-8"?>';
- ?>
- <rss version="2.0"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- xmlns:media="http://search.yahoo.com/mrss/"
- 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>Website.com</title>
- <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
- <link>https://www.website.com</link>
- <description>Website description</description>
- <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
- <language>hr</language>
- <sy:updatePeriod>hourly</sy:updatePeriod>
- <sy:updateFrequency>1</sy:updateFrequency>
- <image><title>Racunalo.com</title><url>https://www.website.com/logo_rss.png</url><link>https://www.website.com</link><width>125</width><height>40</height><description>Publikacije i vijesti iz svijeta poslovanja i tehnologije</description></image>
- <?php if($query_gnr->have_posts()): while($query_gnr->have_posts()): $query_gnr->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>
- <?php
- $thumbnail_ID = get_post_thumbnail_id($post->ID);
- $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumb');
- $mime_vrsta = get_post_mime_type( $thumbnail_ID );
- ?>
- <media:content url="<?php echo $thumbnail[0]; ?>" type="<?php echo $mime_vrsta; ?>" expression="full" width="1200" height="675">
- <media:description type="plain">
- <![CDATA[Photo desc - <?php the_title_rss(); ?>]]>
- </media:description>
- <media:credit role="author" scheme="urn:ebu">
- <![CDATA[Website.com - <?php the_author(); ?>]]>
- </media:credit>
- </media:content>
- <?php the_category_rss( 'rss2' ); ?>
- <guid isPermaLink="false"><?php the_guid(); ?></guid>
- <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
- <?php
- //$content = get_the_content_feed( 'rss2' );
- //$content = apply_filters( 'the_content', get_the_content() );
- //$content = str_replace( ']]>', ']]>', $content );
- // code for spliting content after <h2>...</h2> to insert "AD block", which not parsed and displayed here
- $sadrzaj = get_extended($post->post_content);
- $sadrzaj['main'] = $sadrzaj['main'].'</h2>';
- $prvi = apply_filters('the_content', $sadrzaj['main']);$sadrzaj['extended'] = $sadrzaj['extended'];
- $sadrzaj['extended'] = str_replace('</h2>','',$sadrzaj['extended']);
- $drugi = apply_filters('the_content', $sadrzaj['extended']);
- $prvi_skoro = str_replace("</h2>\n</h2>","</h2>",$prvi);
- //echo str_replace(".</p>","",$prvi_skoro);
- $procisceni = str_replace('</h2><p>','<p>',$drugi);
- ?>
- <content:encoded><![CDATA[<?php echo str_replace(".</p>","",$prvi_skoro); echo $procisceni; ?>]]></content:encoded>
- <?php rss_enclosure(); ?>
- <?php do_action('rss2_item'); ?>
- </item>
- <?php endwhile; endif; wp_reset_postdata(); ?>
- </channel>
- </rss>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement