<?php
/*
Plugin Name: WP Search Plugin
URI: http://www.matthewstevenkelly.com/
Description: A search to add to posts/pages.
Author: Matthew Steven Kelly
Version: 1.0
Author URI: http://www.matthewstevenkelly.com
*/
$wp_search = new wp_search();
add_shortcode("wp_search", array($wp_search, 'shortcodes'));
class wp_search
{
function shortcodes($atts) {
extract(shortcode_atts(array(
"title" => "Search"
), $atts));
$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
<center><table cellpadding="5" cellspacing="0"><tr>
<td><p>' . $title . '</p></td>
<td><input type="text" value="' . get_search_query() . '" name="s" id="s" /></td>
<td><input type="submit id="searchsubmit" value="'. esc_attr__('Search') .'" /></td>
</tr></table></center>
</form>';
return $form ;
}
}
?>
[wp_search title="Search our community for"]
--------------Wordpress.com website is a great reference for more specifics for tweaking your short code plugins: http://codex.wordpress.org
< ? php
/*
Plugin Name: Plugin name that describes
URI: www.yourwebsiteurl.com
Description: Description of plugin
Author: Your name
Version: Version number, start with "1.0"
Author URI: www.yourwebsiteurl.com
*/
$ wp_search = new wp_search();
add_shortcode(" wp_search", array($ wp_search, 'shortcodes'));
class wp_search
{
function shortcodes($atts) {
extract(shortcode_atts(array(
" title" => " Search"
), $atts));
$form = "dynamic html generated by php code";
return $form ;
}
}
? >
--------------
<?php
/*
Plugin Name: WP Sitemap
Plugin URI: http://www.matthewstevenkelly.com/
Description: A HTML sitemap with both post and pages. Good for people and search engines.
Author: Matthew Steven Kelly
Version: 1.0
Author URI: http://www.matthewstevenkelly.com
*/
$wp_sitemap = new wp_sitemap();
add_shortcode("wp_sitemap", array($wp_sitemap, 'shortcodes'));
class wp_sitemap
{
private function generate_sitemap($exclude, $include, $posts, $pages, $sort_order, $sort_column, $paging_position, $post_count)
{
global $wpdb;
global $post;
global $paged;
$tmp_post = $post;
$output = '<div id="sitemap-bg">';
$output .= '<table cellpadding="0" cellspacing="5">';
$loopcount = 3;
$catcount = 0;
// Add categories you'd like to exclude in the exclude here
$cats = get_categories('exclude=');
foreach ($cats as $cat)
{
if($cat->parent==0)
{
if($catcount==0) {$output .= '<tr>';}
$output .= '<td>';
$output .= '<ul class="wp-sitemap">';
$output .= '<li><a href="/categories/'.$cat->slug.'"><h3 style="padding-bottom:0px;margin-bottom:0px;">'.$cat->cat_name.'</h3></a>';
$output .= '<ul>';
$posts = get_posts(array( 'category' => $cat_>catID, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any', 'numberposts' => 100 ));
if ($posts)
{
foreach($posts as $post)
{
setup_postdata($post);
$category = get_the_category();
// Only display a post link once, even if it's in multiple categories
if ($category[0]->cat_ID == $cat->cat_ID) {
$output .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
}
}
}
$output .= "</ul>";
$output .= "</li>";
$output .= "</ul>";
$output .= "</td>";
$catcount += 1;
if($catcount==$loopcount) {$output .= '</tr>'; $catcount = 0;}
}
}
if($catcount!=0) {$output .= '</tr>';}
$output .= '</table>';
$output .= '</div>';
$post = $tmp_post;
return $output;
}
function shortcodes($atts) {
extract(shortcode_atts(array(
"exclude" => 0,
"include" => 0,
"posts" => "true",
"pages" => "true",
"sort_column" => "post_date",
"sort_order" => "DESC",
"paging_position" => "bottom",
"post_count" => 50
), $atts));
$output = '';
$output .= $this->generate_sitemap($exclude, $include, $posts, $pages, $sort_order, $sort_column, $paging_position, $post_count);
return $output;
}
}
?>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)