Skip to content

Instantly share code, notes, and snippets.

@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:25
Add custom field to post
echo get_post_meta($post->ID, 'customFieldName', true);
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:27
Add title permalink with attribute
echo '<a class="permaLink" href="';
echo the_permalink();
echo'" title="';
echo the_title_attribute();
echo'">';
echo the_title();
echo '</a>';
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:28
Include SVG to HTML
<object type="image/svg+xml" data="image.svg">Your browser does not support SVG</object>
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:30
Post loop
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// add title, content, custom field, ...
echo '<div class="posts">';
echo the_title();
echo get_the_content();
//the_content('Preberi več...');
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:32
Register menus
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'MainMenu' ),
'footer-menu' => __( 'FooterMenu' ),
'left-menu' => __( 'LeftSideMenu' )
)
);
}
add_action( 'init', 'register_my_menus' );
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:35
Dropdown bootstrap menu
https://github.com/twittem/wp-bootstrap-navwalker
http://astronautweb.co/2012/10/wordpress-dropdown-bootstrap/
http://code.tutsplus.com/tutorials/how-to-integrate-bootstrap-navbar-into-wordpress-theme--wp-33410
// insert in menu code instead of wordpress menu code
<?php
wp_nav_menu( array(
@ABooooo
ABooooo / new_gist_file_0.php
Last active November 1, 2018 08:21
Hide admin bar on page preview
add_filter('show_admin_bar', '__return_false');
@ABooooo
ABooooo / new_gist_file_0
Created August 19, 2014 07:36
Allow SVG
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
<?php
/* Always have wp_footer() just before the closing </body>
* tag of your theme, or you will break many plugins, which
* generally use this hook to reference JavaScript files.
*/
wp_footer();
?>
// insert before </head>
<?php wp_head(); ?>