Skip to content

Instantly share code, notes, and snippets.

<?php $page_contents = get_post();
// use print_r if you want to see everything in the array
// print_r($page_contents);
$page_data = $page_contents->post_content; ?>
<div><?php echo $page_data ?></div>
var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
// where dist is the desired folder
git subtree push --prefix dist heroku master
// in .htaccess
<FilesMatch "\.(mov|mp3|mp4|wav|pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
add_action("publish_post", "eg_create_sitemap");
add_action("publish_page", "eg_create_sitemap");
function eg_create_sitemap() {
$postsForSitemap = get_posts(array(
'numberposts' => -1,
'orderby' => 'modified',
'post_type' => array('post','page'),
'order' => 'DESC'
));
<?php $page_id = get_page_by_title($page->page_title);
$page_data = get_page($page_id); ?>
<p><?php echo $page_data->post_content; ?></p>
<?php
if ( ! current_user_can( 'manage_options' ) ) {
add_action( 'admin_menu', 'admin_menu_example' );
}
function admin_menu_example() {
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
// In functions.php. Creates accessible array of bloginfo parameters
// http://codex.wordpress.org/Template_Tags/bloginfo
function bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
'key' => '',
), $atts));
return get_bloginfo($key);
}
add_shortcode('bloginfo', 'bloginfo_shortcode');
@alwerner
alwerner / Wordpress Custom Post Type Pagination
Last active December 1, 2015 22:40
for "news" custom post type
<?php
// Define custom query parameters
$custom_query_args = array(
'post_type' => 'news',
'orderby' => 'asc',
'paged' => $paged,
'posts_per_page' => 2
);