Skip to content

Instantly share code, notes, and snippets.

View SolomashenkoRomanWork's full-sized avatar

Solomashenko Roman SolomashenkoRomanWork

View GitHub Profile
@skydriver
skydriver / first-title-letter-query.php
Created April 18, 2014 12:13
WordPress List Posts by First Title Letter
<?php
global $wpdb;
$first_char = esc_attr($_GET[$search_key]);
$postids = $wpdb->get_col($wpdb->prepare("
SELECT ID
FROM $wpdb->posts
WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s
AND $wpdb->posts.post_type = 'product'
@alana-mullen
alana-mullen / Detect the last post in the WordPress loop
Last active May 29, 2023 16:50
Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@leoken
leoken / redirect-parent-to-child.php
Created December 28, 2012 06:56
Redirect Parent to First Child - WordPress Plugin
<?php
/*
Plugin Name: Redirect Parent to First Child
Plugin URI: http://www.nathanrice.net/parent-to-first-child
Description: This plugin will do a 301 redirect on top-level parent pages, to their first child page, based first on menu order, then post title if no menu order is set. It only redirects if a *published* child page actually exists.
Version: 0.1
Author: Nathan Rice
Author URI: http://www.nathanrice.net/
License: This plugin is licensed under GPL.