Insert Google Adsense in Between Gallery Rows
Filed in: Adsense Tips, Make Money Online, Open Source, Web Development — March 4th, 2005

Google Adsense in between Gallery rows
I use Gallery for my gallery page, with Google Adsense ads. By Integrate Gallery into Wordpress, I am able to add Adsense code at page header and/or footer.
But, since my album is displayed in 3 rows, I think putting Adsense ads in between Gallery rows will better increase the appearance and click rate(hopefully
).
Problem
I search through Internet but failed to find helpful resources. The “html_wrap” files only support for Header, Footer, and Frame. Doesn’t has html wrap for Gallery Rows.
At the end, I solved it by myself with dirty trick. Read on for details.
Solution
Since html_wrap does not help this time. I modified the “view_album.php” file to get my ads display in between rows. “view_album.php” is the PHP file to display photo albums in Gallery.
Warning! Editing “view_album.php” is NOT recommended. Make sure you have backup the file first before modify it. Backup!
Insert Google Adsense Code In Between Gallery Rows
- Backup “
view_album.php” file! - Open “
view_album.php" for editing. - Search for the following lines of code:
[php]if ($printTableRow) {
echo('');
}
$rowCount++;
$rowStart = $visibleItemIndex;[/php] - Insert your Google Adsense code AFTER:
[php]if ($printTableRow) {
echo('');[/php]
and, BEFORE :
[php]}
$rowCount++;
$rowStart = $visibleItemIndex;[/php] - If you are doing it right, it will looks something like this:
[php]if ($printTableRow) {
echo('');
// START - Insert adsense in between Gallery row
?>
}
$rowCount++;
$rowStart = $visibleItemIndex;[/php] - Save the modified "
view_album.php" file and upload back to your Gallery folder. Backup the file before replace! - Done!
Note: The sample Adsense code is mine. If you use it in your Gallery, I am the one who get the money! It is highly recommended!
Thought:
Actually, this trick is quite simple but editing Gallery PHP file is never be recommended. If you want to modify it, please do backup.
Comments Feed
TrackBack URL

