Difference between revisions of "Wordpress"

From Wikicliki
Jump to: navigation, search
 
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
*http://fthrwght.com/autofocus/
+
== did featured image disappear when you ported your theme over, add this to functions to fix it ==
*http://shakenandstirredweb.com/331/introducing-our-first-free-wordpress-theme-shaken-grid
+
 
*http://www.frogsthemes.com/themes/wordpress/foliogrid-pro/
+
<pre>
 +
add_theme_support( 'post-thumbnails' );
 +
</pre>
 +
 
 +
== custom search form ==
 +
 
 +
<pre><form action="/" method="get">
 +
    <fieldset>
 +
        <label for="search">Search in <?php echo home_url( '/' ); ?></label>
 +
        <input type="text" name="s" id="search" value="<?php the_search_query(); ?>" />
 +
        <input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search.png" />
 +
    </fieldset>
 +
</form></pre>
 +
 
 +
== Homepage link ==
 +
 
 +
<pre><a href="<?php bloginfo('url');?>">Home</a></pre>
 +
 
 +
== Widgetising the menu ==
 +
 
 +
Add this to functions.php:
 +
 
 +
<pre>
 +
 
 +
register_sidebar( array(
 +
'name' => 'Page Menu',
 +
'id' => 'page-menu',
 +
'before_widget' => '<div id="page-nav">',
 +
'after_widget' => '</div>',
 +
'before_title' => false,
 +
'after_title' => false
 +
) );
 +
 
 +
add_filter( 'wp_page_menu', 'my_page_menu' );
 +
 
 +
function my_page_menu( $menu ) {
 +
dynamic_sidebar( 'page-menu' );
 +
}
 +
 
 +
</pre>
 +
 
 +
Add this to your wordpress theme where the menu should appear
 +
 
 +
<pre><?php wp_page_menu(); ?></pre>
 +
 
 +
 
 +
== widgetising the sidebar ==
 +
 
 +
* http://codex.wordpress.org/Widgetizing_Themes
 +
 
 +
== steps for widgetising a wordpress theme ==
 +
 
 +
# register the widget area in functions.php
 +
# add the code for the widget area in your theme
 +
# style the widget in css
 +
 
 +
<pre><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Sidebar') ) : ?>
 +
<?php endif; ?>
 +
</pre>
 +
 
 +
 
 +
in functions.php
 +
 
 +
<pre>if ( function_exists('register_sidebars') ) {
 +
    register_sidebar(array('name'=>'Homepage Sidebar',));
 +
    register_sidebar(array('name'=>'Another Sidebar',));
 +
    register_sidebar(array('name'=>'Yet another Sidebar',));
 +
    register_sidebar(array('name'=>'What more Sidebar',));
 +
}</pre>
 +
 
 +
== Importing / exporting xml ==
 +
 
 +
* [http://suhastech.com/wordpress-wxr-xmlfile-splitter-for-mac-os-x/ WordPress WXR file splitter for Mac OS X] - to split xml into 2MB for upload (maximum file limit is 2MB but you can split the wxr xml into different files and upload one by one instead.
 +
 
 +
== Geotagging ==
 +
 
 +
http://www.lucianmarica.com/stuff/geotagging-from-image-exif-data-in-wordpress/
 +
 
 +
== Snippets ==
 +
 
 +
<pre><?php
 +
if ( in_category('fruit') ) {
 +
include 'single-fruit.php';
 +
} elseif ( in_category('vegetables') ) {
 +
include 'single-vegetables.php';
 +
} else {
 +
// Continue with normal Loop
 +
if ( have_posts() ) : while ( have_posts() ) : the_post();
 +
// ...
 +
}
 +
?></pre>
 +
 
 +
<pre><?php if ( get_post_meta($post->ID, 'thumb', true) ) : ?>
 +
    <a href="<?php the_permalink() ?>" rel="bookmark">
 +
        <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />
 +
    </a>
 +
<?php endif; ?></pre>

Latest revision as of 02:00, 27 May 2013

did featured image disappear when you ported your theme over, add this to functions to fix it

add_theme_support( 'post-thumbnails' ); 

custom search form

<form action="/" method="get">
    <fieldset>
        <label for="search">Search in <?php echo home_url( '/' ); ?></label>
        <input type="text" name="s" id="search" value="<?php the_search_query(); ?>" />
        <input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search.png" />
    </fieldset>
</form>

Homepage link

<a href="<?php bloginfo('url');?>">Home</a>

Widgetising the menu

Add this to functions.php:


register_sidebar( array(
	'name' => 'Page Menu',
	'id' => 'page-menu',
	'before_widget' => '<div id="page-nav">',
	'after_widget' => '</div>',
	'before_title' => false,
	'after_title' => false
) );

add_filter( 'wp_page_menu', 'my_page_menu' );

function my_page_menu( $menu ) {
	dynamic_sidebar( 'page-menu' );
}

Add this to your wordpress theme where the menu should appear

<?php wp_page_menu(); ?>


widgetising the sidebar

steps for widgetising a wordpress theme

  1. register the widget area in functions.php
  2. add the code for the widget area in your theme
  3. style the widget in css
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Sidebar') ) : ?>
	<?php endif; ?>


in functions.php

if ( function_exists('register_sidebars') ) {
    register_sidebar(array('name'=>'Homepage Sidebar',));
    register_sidebar(array('name'=>'Another Sidebar',));
    register_sidebar(array('name'=>'Yet another Sidebar',));
    register_sidebar(array('name'=>'What more Sidebar',));
}

Importing / exporting xml

Geotagging

http://www.lucianmarica.com/stuff/geotagging-from-image-exif-data-in-wordpress/

Snippets

<?php
if ( in_category('fruit') ) {
	include 'single-fruit.php';
} elseif ( in_category('vegetables') ) {
	include 'single-vegetables.php';
} else {
	// Continue with normal Loop
	if ( have_posts() ) : while ( have_posts() ) : the_post();
	// ...
}
?>
<?php if ( get_post_meta($post->ID, 'thumb', true) ) : ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">
        <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />
    </a>
<?php endif; ?>