Tag: Wordpress
Calling a Wordpress loop from inside a Wordpress loop
Recently I came across a sitution whereby I wanted to call a list of Wordpress posts from inside the body of another post, i.e., not coding it into a template, but embedding into the body of the post itself. Not a big drama
, I thought to myself: I already have the exec-php plugin installed to enable the execution of PHP from within Wordpress posts, so all I needed to do was call the Wordpress loop from the point inside the post where I wanted my list of links to appear, e.g.:
<ul>
<php $my_query = new WP_Query('cat=XX');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<php the_permalink(); ?>"><php the_title(); ?></php></a></li>
</php><php endwhile; ?>
</php></ul>
More on Calling a Wordpress loop from inside a Wordpress loop
Fetching posts in Wordpress and ExpressionEngine with jQuery and AJAX
Recently I was asked by a client to do some customisation of a Wordpress site to enable a site visitor to load posts from a certain category into the same part of the page via AJAX. This could have been done in a couple of different ways – using AJAX as requested; or all the posts could’ve been printed to the page, with javascript then used to hide all but one and also used to navigate between them in some sort of hide/show, fading/sliding effect. I’ve done similar things like this before using jQuery, but there were two reasons why I didn’t go that route on this occasion:
- With javascript turned off, all the posts from the selected category would’ve been displayed on the page and as the design called for three short columns of text on the page, having one column much, much longer than the other two would really have looked wrong.
- The client specifically asked for AJAX to be used.
More on Fetching posts in Wordpress and ExpressionEngine with jQuery and AJAX
Connecting to an external database from within a Wordpress post
For the article I wrote recently on web design galleries, I compiled a table of the galleries in a MySQL database. To be able to display the table and the associated charts and other statistics that went with it, I needed to be able to connect to this external database from within Wordpress.
More on Connecting to an external database from within a Wordpress post
The Ultimate Web Design Gallery Resource
< ?php
$docroot = $_SERVER[‘DOCUMENT_ROOT’];
include($docroot.’/shed/galleries/conn.php’);
include($docroot.’/shed/galleries/countries.php’);
include($docroot.’/shed/galleries/queries.php’);
?>
In case you haven’t noticed lately, there a LOT of web design galleries out there. I’d always kept bookmarks for the galleries I’d come across but recently while looking at one I noticed links to a lot of galleries that I hadn’t heard of before. So I thought it might be worthwhile to investigate just how many there were out there. I came across a few blog posts with links to galleries but rather than just adding to the list and then publishing it, I thought I’d do a bit more investigation and analysis.
Catching content copiers with Wordpress
I recently had one of the articles from this site copied and posted on someone else’s site (a practice sometimes also known as site scraping). But thanks to a couple of Wordpress’ in-built features and also a handy plugin, I soon found about it.
Content negotiation
Content-Negotiation is a mechanism defined in the HTTP specification that makes possible to serve different “versions” of a document (or more generally of a resource) at the same URL, so that user agents can choose which version fit their capacities the best. W3C
User-defined accesskeys
This site enables users to define their own accesskeys. The PHP script that does the work comes courtesy of Dan Champion at Blether. Dan’s article on how to use the script is fairly straight-foward except that when combined with a Wordpress site, a couple of modifications are required.






