Using Google Site Search with WordPress

by webhank on April 1, 2010

in Articles

I recently installed Google Site Search on a WordPress site.  When I did, I kept getting an error stating that I did not have permissions to access that page – Forbidden… at any rate here is the fix.

I logged into your GSS account and tried to perform a search from the “Preview” section of your GSS control panel and it did gave me the error message “Forbidden”.

On further investigating it appears that your GSS account has the mode set to “BOOST” in the context under “Advanced” tab. The mode BOOST is used in CSE were the entire web has to be searched. But this is not possible with GSS, so you need to change that
option before upgrading as mentioned in this document.

http://www.google.com/support/customsearch/bin/answer.py?answer=72323&topic=11504

So to fix this issue, you need to change the mode from BOOST to FILTER in the context XML.

The context file shows the following label:

<Label name=”_cse_6nkyxsvqqeq” mode=”BOOST” />

change it to

<Label name=”_cse_6nkyxsvqqeq” mode=”FILTER” />

So you need to do the following:

1. On your control panel goto Advanced > Context section.
2. Under “Upload context” click the “Download in XML format”.
3. Now in that file find this line:
<Label name=”_cse_6nkyxsvqqeq” mode=”BOOST” />

replace it with

<Label name=”_cse_6nkyxsvqqeq” mode=”FILTER” />
4. Now upload the context XML file back with the changes.

{ 0 comments }

List WordPress posts by author

by webhank on July 8, 2009

in Articles, Tutorials

On my archive page, I wanted to be able to list posts by author.  I ran across this script online, and it works, but lists posts, pages, and revisions by a particular author, which makes for a rather lenghty list.

<?php $numposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_author = " . $curauth->ID); ?>
          <?php foreach ($numposts as $numpost) {
               $link = get_permalink( $numpost->ID );
               echo '<a href="' . $link . '">'.$numpost->post_title."</a>\n";
          } ?>
</div>

Adding post_status=’publish’ AND post_type=’post’ to the query limited this to just published posts but i wanted to also have the post name link to the post page.

I added this to the code:

<?php $numposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status='publish' AND post_type='post' AND post_author = " . $curauth->ID . " ORDER BY post_modified LIMIT 1"); ?>
     <div class="alignleft">
          most recent post: 
          <?php foreach ($numposts as $numpost) {
               $link = get_permalink( $numpost->ID );
               echo '<a href="' . $link . '">'.$numpost->post_title."</a>\n";
          } ?>
     </div>
 
<div class="alignright">
     <a href="<?php echo $user_link; ?>" title="see all posts by <?php echo $curauth->display_name; ?>">view all contributions by this author</a>
</div>

Hope that helps someone else out.

{ 0 comments }

Want to list Authors in Your WordPress Sidebar?

June 19, 2009

If you have a multi-author blog, listing the autors and editors in your side bar can be very helpful to your readers. Here’s how to do it – short and sweet!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$roles = array(’administrator’, ‘editor’, ‘author’, ‘contributor’, ’subscriber’);
 
/* Loop through users to search for the admin and editor users. */
foreach( $roles as $role ){
[...]

Read the full article →

Show Revision Thread on WordPress Posts

June 16, 2009

If you follow this blog with any frequency, you’re probably tired of hearing “so i was working on this project that required a bunch of customization of WordPress” – so I will skip that part and just dive in.
Want to show the revision threads below a single post to allow visitors to see how your [...]

Read the full article →

Display Archives by Category in WordPress

June 16, 2009

I have been tweaking a WordPress install for a project that will result in a fairly customized product when I am done (can’t wait to show it off). The most recent challenge I found was the need to show archives by category. Truthfully, I was kind of shocked that this wasn’t included with [...]

Read the full article →

Create an Authors list page for WordPress

June 15, 2009

When you have a multiple autor blog, a nice touch is to have a page that lists out each of the authors with a little description/bio. All of these fields are updatable in the WordPress admin – here’s a way to display them on your blog as a template.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// Get the authors from [...]

Read the full article →

What’s new with WordPress 2.8?

June 11, 2009

here’s a quick list of what i’ve found so far

a new tab in the admin called “post tags” under the posts header allows you to view all used tags and modify them – much like categories.
easier theme management – although i didn’t really mind how it was before
page and sub page ordering
browse new themes right [...]

Read the full article →

modifying the WordPress Dashboard

June 9, 2009

a site i am currently deploying on WordPress will have many of the users actually accessing the admin area of the site. as such, i wanted to modify the default dashboard, clean up a few things and add some messaging to the users – a “welcome to the admin area” if you will. [...]

Read the full article →

Custom Style for WordPress Admin

June 9, 2009

recently I’ve been working on a project that requires a great deal of customization of the WordPress admin area.  I never like to edit the core files, one there is no real need to and two – that really makes upgrading a pain – so here’s how i went about it.
Feel free to leave comments.
The [...]

Read the full article →

Interesting Article About Fluid Width Images and Objects

April 26, 2009

Interesting concept for developers using fluid layouts.
http://unstoppablerobotninja.com/entry/fluid-images/

Read the full article →