Skip to content

Instantly share code, notes, and snippets.

@mzo84
mzo84 / the-loop.php
Last active August 16, 2016 06:12
wordpress loop
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>
@mzo84
mzo84 / global-custom-field.php
Created August 15, 2016 10:55
Add a global custom field
// Add this to your functions.php:
<?php add_action('admin_menu', 'add_gcf_interface');
function add_gcf_interface() {
add_options_page('Global Custom Fields', 'Global Custom Fields', '8', 'functions',
'editglobalcustom elds');
}
function editglobalcustom elds() { ?>
<div class="wrap">
<h2>Global Custom Fields</h2>
<form method="post" action="options.php">
@mzo84
mzo84 / seo-friendly-title.php
Created August 15, 2016 08:23
<title> tag for bookmark friendly links
<title>
<?php if (function_exists('is_tag') && is_tag()) {
single_tag_title('Tag Archive for &quot;'); echo '&quot; - ';
} elseif (is_archive()) {
wp_title(''); echo ' Archive - ';
} elseif (is_search()) {
echo 'Search for &quot;'.wp_specialchars($s).'&quot; - ';
} elseif (!(is_404()) && (is_single()) || (is_page())) {
wp_title(''); echo ' - ';
} elseif (is_404()) {
@mzo84
mzo84 / custom-taxonomies.php
Last active August 14, 2016 08:20
wordpress - add custom taxonomies example
// Add to functions.php within the theme folder.
function create_my_taxonomies() {
register_taxonomy('actors', 'post', array(
'hierarchical' => false, 'label' => 'Actors',
'query_var' => true, 'rewrite' => true));
register_taxonomy('producers', 'post', array(
'hierarchical' => false, 'label' => 'Producers',
'query_var' => true, 'rewrite' => true));
}
@mzo84
mzo84 / .htaccess
Created July 10, 2016 05:48
pretty url htaccess for yii 2 - put in /web folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?basic/(.*)$ /basic/index.php/$1 [L]