I am trying to get multiple feeds from various sites. But whenever I run the script it gives me feeds from either one site and sometimes from all the sites specified in the script.
Here is the code from Simplepie -
/ Include the SimplePie library
// For 1.0-1.2:
#require_once('simplepie.inc');
// For 1.3+:
require_once('autoloader.php');
// Create a new SimplePie object
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://digg.com/rss/index.xml',
'http://feeds.tuaw.com/weblogsinc/tuaw',
'http://feeds.uneasysilence.com/uneasysilence/blog'
));
// We'll use favicon caching here (Optional)
$feed->set_favicon_handler('handler_image.php');
// Initialize the feed object
$feed->init();
// This will work if all of the feeds accept the same settings.
$feed->handle_content_type();
// Begin our XHTML markup
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Awesome feeds</title>
<link rel="stylesheet" href="../demo/for_the_demo/simplepie.css"
type="text/css" media="screen" charset="utf-8" />
<style type="text/css">
h4.title {
/* We're going to add some space next to the titles so we can fit
the 16x16 favicon image. */
background-color:transparent;
background-repeat:no-repeat;
background-position:0 1px;
padding-left:20px;
}
</style>
</head>
<body>
<div id="site">
<?php if ($feed->error): ?>
<p><?php echo $feed->error; ?></p>
<?php endif; ?>
<h1>Awesome feeds</h1>
<?php foreach ($feed->get_items() as $item): ?>
<div class="chunk">
<?php /* Here, we'll use the $item->get_feed() method to gain access to the parent feed-level data for the specified item. */ ?>
<h4 class="title" style="background-image:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>);"><?php echo $item->get_title(); ?></h4>
<?php echo $item->get_content(); ?>
<p class="footnote">Source: <?php $feed = $item->get_feed(); echo $feed->get_title(); ?> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>
</div>
<?php endforeach; ?>
</div>
Does anybody have idea what is going wrong with the current script??
I searched for information related to this but I got no help.
What I do is limit the number of items per feed in my config code so that you get some from each feed. Because it sorts by date, if one feed has 15 items that are more recent than any of your other feeds, you'll get those first and you might not see any items from the other feeds.
$max_items_per_feed = 3;
// limit the number of items
$feed->set_item_limit($max_items_per_feed);
Related
I have a problem where custom theme does not load plugins files on custom theme page.
When switching to default theme plugins files get loaded correctly on the same page.
I am not sure if I am missing something as all action hooks that I could find mandatory are included.
Any guidance or help will be much appreciated, thanks.
Custom theme page setup is as follows:
header.php contents:
<!doctype html>
<html lang="en-US">
<head>
<?php wp_head();?>
</head>
page-custom.php contents:
<?php get_header(); ?>
<body>
<?php
// content
$content_post = get_post(125); // 125 equals id of the custom page
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
// footer
get_footer();
?>
footer.php contents:
<?php
wp_footer();
?>
</body>
</html>
I would look through the plugin's code to see what it's actually hooking into and figuring out if it's something missing from the template your theme is loading on a certain page.
I have been researching a problem that I have and came across this discussion:
https://gtranslate.io/forum/how-not-translate-the-title-meta-tag-t4852.html
In there the answer provided is to use this html syntax:
<title class="notranslate">Example</title>
The issue at hand is to prevent Google Translate from translating the <title> tag. What I have is a WordPress website:
www.publictalksoftware.co.uk
I don't know how to go about changing the site to apply this syntax for all the <title> tags on my posts and pages. I read up about wp_head() but am getting lost.
Any advice appreciated.
Update
The header.php for the theme I am using has this code:
<?php wp_head(); ?>
<?php if ( get_option('google_analitic_code') ) : ?>
<?php echo get_option('google_analitic_code'); ?>
<?php endif; ?>
</head>
Add Below function in function.php
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
Add Below code in header.php befode wp_head();
<title class="notranslate"><?php bloginfo('name');?> | <?php wp_title();?></title>
Hope this works for you.
Here is my code from header
<meta charset="<?php bloginfo('charset'); ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<title><?php wp_title('|', true, 'right'); ?></title>
<?php wp_head(); ?>
....
I have no active plugins.
there are 2 filters for wp_head - none is used to displayed ' title ',
also there is no other wp_title or ' title ' in the whole theme code.
Any ideas about how i can remove the second title?
From a post I have recently done on WPSE
The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and actually is using 4.1. As from 4.1 you don't need to call wp_title() in the head any more, you can make use of new title_tag theme support tag which automatically adds the wp_title() tag in the header
The parent theme you are using are most probably already doing this. Look in your functions.php for this line of code
add_theme_support( 'title-tag' );
As a solution, copy the parent theme header.php to your child theme and simply remove the wp_title() function from the child theme header.php
Here is also a great function to keep in mind for backwards compatibility and is useful for parent theme developers: (Taken from the codex)
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function theme_slug_render_title()
{
?>
<title>
<?php wp_title( '|', true, 'right' ); ?>
</title>
<?php
}
add_action( 'wp_head', 'theme_slug_render_title' );
}
I have this plugin installed "Category Images" which basically helps me add an image for a category. it works fine.
but when i view my post, say for example a post from category "movies". can i use the background image of the category(movies) has the background image for single post of category(movies)?
this helps me get the link of the category image.(plugin)
<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?>
i tried this code
<style type="text/css">
body.single{
background-image:url(<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?>);
}
</style>
thank you
If you want to address the body element, the following could work:
<?php if ( is_single() && function_exists('z_taxonomy_image_url') ): ?>
<style type="text/css">
body {
background-image:url(<?php echo z_taxonomy_image_url(); ?>);
}
</style>
<?php endif; ?>
http://codex.wordpress.org/Function_Reference/is_single
...you also might need to pass the image function a category ID, if you're not on a archive page:
<?php $category = get_the_category(); ?>
background-image:url(<?php echo z_taxonomy_image_url(category[0]->term_id); ?>);
http://codex.wordpress.org/Function_Reference/get_the_category
Perhaps you meant:
body .single{
instead of
body.single{
I am showing a wordpress feed through this client's site, http://www.redvaultproductions.com/Latest.php, but videos do not show within the posts.
Notice the second (when I wrote this) post "Mount Bachelor, Oregon," it has a video on the wordpress - seen here http://redvaultproduction.wordpress.com/2012/11/14/mount-bachelor-oregon/ - but not on my client's site.
here is what's at the top of the document
<?php
require_once('autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url('http://redvaultproduction.wordpress.com/feed/');
$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(120);
$feed->init();
$feed->handle_content_type();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
and here is what is on the document for every post.
<?php
$item = $feed->get_item() ?>
<div class="postTitleTop"><br />
<?php print $item->get_title(); ?></div>
<?php print $item->get_content(); ?>
Can anyone help explain? I can't find any info on this.
SimplePie automatically removes these HTML tags: 'base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'.
You have to specify which tags you dont want to remove like this:
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
// Remove these tags from the list
$strip_htmltags = $feed->strip_htmltags;
array_splice($strip_htmltags, array_search('object', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('param', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('embed', $strip_htmltags), 1);
$feed->strip_htmltags($strip_htmltags);
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();
http://simplepie.org/wiki/reference/simplepie/strip_htmltags