Skip to content

Instantly share code, notes, and snippets.

<div class="carousel-inner">
<?php
$first = true;
while ( have_posts() ) : the_post();
$content = get_the_content();
?>
<div class="item <?php echo ( $first ? 'active' : 'inactive' ); ?>">
<div class="container slide-element">
<?php the_post_thumbnail(); ?>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
@Clorith
Clorith / gist:2843d156df053e584393
Created December 5, 2014 07:26
Get any WordPress post without any tags
<?php
global $wpdb;
$entries = $wpdb->get_results( $wpdb->prepare( "
SELECT
p.ID,
t.term_id
FROM
" . $wpdb->posts . " p
LEFT JOIN
@Clorith
Clorith / gist:dc8485bacce8f52d9389
Created November 29, 2014 08:29
fail2ban filter.d/wordpress.conf for WordPress bruteforce protection
# Fail2Ban configuration file
#
# Author: Marius
#
[INCLUDES]
before = common.conf
[Definition]
@Clorith
Clorith / gist:52af851d2cc2e262cf13
Created November 29, 2014 08:20
fail2ban jail.conf block for WordPress
[wordpress]
enabled = true
bantime = 900
port = http,https
filter = wordpress
logpath = /var/log/apache2/other_vhost_access.log
findtime = 8
maxretry = 5
<?php
function login_redirection( $redirect_to, $request, $user ) {
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) || in_array( 'editor', $user->roles ) ) {
return $redirect_to;
}
else {
return home_url( '/dekk/' );
@Clorith
Clorith / gist:ec4474271b067b463e4a
Created November 4, 2014 06:31
Print styling for uber.com receipts
@media print {
.nav--block,
.hidden--portable,
#trip-details__actions {
display: none;
}
.page-container {
border: none;
}
<?php
// This is your functions.php
function exclude_first_five_posts_home( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'offset', '5' );
}
}
add_action( 'pre_get_posts', 'exclude_first_five_posts_home' );
SELECT
(
SELECT
COUNT(DISTINCT id)
FROM
messages
WHERE
nickname = '" . $_GET['nickname'] . "'
AND
is_question = 1
ASCII GS ( L pL pH m fn # # 1 1
Decimal 29 40 76 6 0 48 69 35 35 49 49
<?php
function set_page_for_post( $query ) {
/*
* Only run our query modifications if;
* This is the main query (not a custom WP_Query or similar)
* We are not on the admin screen
* It's a single post entry
* The post type is 'post'
*/
if ( $query->is_main_query() & ! is_admin() && is_single() && 'post' == get_post_type() ) {