Tips & Tricks
How to: Display RSS feeds from anywhere
Here is a simple way to display any RSS feed in your WordPress blog.
<?php include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://feeds2.feedburner.com/WPCult'); $items = array_slice($rss->items, 0, 4); if (empty($items)) echo '<li>No items</li>'; else foreach ( $items as $item ) : ?> <a style="font-size: 14px;" href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a><br /> <p style="font-size: 10px; color: #aaa;"><?php echo date('F, j Y',strtotime($item['pubdate'])); ?></p> <p><?php echo substr($item['summary'],0,strpos($item['summary'], "This is a post from")); ?></p> <?php endforeach; ?>
The first step is to include the WordPress file rss.php
then will apply code after to style the feeds.
Of coarse I forgot to mention, change the RSS feed to the feed you want to pull.
Tips & Tricks
How to: Add a contact me via Skype™ button
This little trick is really simple and easy. All you need to do is plug this line of code anywhere you would like to use the text.
<a onclick="return skypeCheck();" href="skype:austin.passy?call">Call me on Skype!</a>
That’s is, pretty simple huh? Just make sure you change skype:austin.passy to your user name!
Want a test? Well, please use the text button, as I was getting to many call’s and hangups: Call me on Skype! Message me on Skype!
Thanks to Shayne for this code!
Update:
I was reminded by Shayne that you will have to add this script into your header.php
file:
<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"> </script>
That way if the user doesn’t have Skype, they will be prompted to download it if they would like :).
Tips & Tricks
How to: show/hide a widget in WordPress with jQuery
In a previous post I talked about how to show/hide a single div
html code with a search inside. Today I’d like to show you how I implemented jQuery into my new theme.
As seen in the current theme, I am using jQuery to animate the show/hide or as known as the css style display: none;
.
Since I am using a custom child theme on my site, and have Hybrid theme as my parent, the widgets or sidebar section is different than may be in your theme. But just apply the the style’s as follows to your theme.
First make sure that your WordPress site is calling jQuery, by plugging in this code into your header.php
file above the <?php wp_head(); ?>
text:
<?php wp_enqueue_script('jquery'); ?>
Then anywhere above the </head
>, plug this code in:
<script type="text/javascript"> function toggleWidgets() { $('#primary h3.widget-title').addClass('plus'); $('#primary h3.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); }); } $(document).ready(function() { toggleWidgets(); } </script>
That’s it. Pretty simple huh.
So lets go over what the code does.
$('#primary h3.widget-title').addClass('plus');
This line finds all <h3>
tags with the class widget-title
inside the ID parameter of #primary
and adds a class of plus
.
Then
$('#primary h3.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); });
Will apply a click function. When the H3 tag is clicked it will remove the class plus
and add the class minus
.
Then the code that says .next
will then toggle the “next” element after the <h3> title.
Tips & Tricks
WordPress Security Hacks
Hi guys this is my first post on wpcult the great site Austin built. Hope you guys find it usefull.
If you run a blog using the wordpress software then your blog is a target to hackers. Below I will list some hacks and just how they can help you keep your business/site safe.
The following is code to Block Bad Queries and protect your blog from malicious URL Requests.
Place the following code into a text file and name it what ever you like for example blockbadqueries.php upload it to your plugin folder and activate it in your wordpress admin just as you would any other Plugin
<?php
/*
Plugin Name: Block Bad Queries
Plugin URI: http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/
Description: Protect WordPress Against Malicious URL Requests
Author URI: http://perishablepress.com/
Author: Perishable Press
Version: 1.0
*/
global $user_ID; if($user_ID) {
if(!current_user_can(‘level_10’)) {
if (strlen($_SERVER[‘REQUEST_URI’]) > 255 ||
strpos($_SERVER[‘REQUEST_URI’], “eval(“) ||
strpos($_SERVER[‘REQUEST_URI’], “CONCAT”) ||
strpos($_SERVER[‘REQUEST_URI’], “UNION+SELECT”) ||
strpos($_SERVER[‘REQUEST_URI’], “base64”)) {
@header(“HTTP/1.1 414 Request-URI Too Long”);
@header(“Status: 414 Request-URI Too Long”);
@header(“Connection: Close”);
@exit;
}
}
}
?>
This Great plugin was made by Jeff Starr of Digging into WordPress
Protecting your blog with .htaccess
.htaccess files have lots of possibilities. below is some code that will help protect your wordpress from modification of _REQUEST and/or GLOBALS and scripts injection.
This is real simple just paste the following code into your .htaccess file. Always make a backup of your .htaccess before editing, better to be safe.
Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule ^(.*)$ index.php [F,L]
Thanks to Oussama for this great hack
-
Tips & Tricks1 month ago
WordPress Security Hacks
-
Pages4 months ago
Write For Us – Guest Post
-
Showcase4 months ago
StylizedWeb.com
-
News4 months ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks3 months ago
Remove the title attribute using jQuery
-
Tips & Tricks1 week ago
How to: show/hide a widget in WordPress with jQuery
-
Plugins3 days ago
Top Membership plugins
-
Tips & Tricks4 months ago
Limit the characters that display on the_title
Septian
March 24, 2009 at 12:56 am
Wow, actually I want to ask you how to do that…but, you already answer it with this post 🙂
anyway, I’ve question for you, please look at your mailbox and answer it ASAP..thx very much…
Peter
March 26, 2009 at 7:23 am
Very cool – I had no idea this functionality was built in. I see quite a few projects where people want this type of thing built, and I had assumed you’d have to build your own parser.
Does anybody know how long Magpie has been in wordpress? This could have saved me lots of time..
Larry
April 8, 2009 at 9:29 pm
Thanks but I need some more direction The code you have listed- where do I put that? In the post or page? Appreciate your time
Edhie Baskoro Yudhoyono Muda Cerdas Jujur Peduli Rakyat
April 12, 2009 at 4:08 pm
Thanks, this information is usefull..
Raymond Ramy
April 14, 2009 at 7:01 pm
..hey.. I think the “summary” is not functioning..
Raymond Ramy´s last blog post..Why Choose Freelance Web Designer?