Skip to content

Instantly share code, notes, and snippets.

harshclimate

Block or report user

Report or block harshclimate

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.php
<?php get_header(); ?>
<?php
$args1 = array(
'post_type' => 'post',
'orderby' => 'rand',
'category_name' => 'wineries',
'posts_per_page' => 1
); $wineries = new WP_Query($args1);
?>
@harshclimate
harshclimate / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
View Mark parent navigation active when on custom post type single page
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
View gist:1c9edad000f46b7b9827b2a3b3833ea9
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@harshclimate
harshclimate / functions.php
Last active Jan 14, 2018
Append the date to main navigation menu via functions.php
View functions.php
<?php
// I need to make sure that scripts and styles are able to be recognized on the website.
function HC_Scripts() {
wp_enqueue_style('style' , get_stylesheet_uri());
wp_enqueue_style('grid' , get_template_directory_uri() .'/grid.css', array(), null, 'all');
wp_enqueue_style('fonts' , 'https://fonts.googleapis.com/css?family=PT+Sans:400,400i|Roboto+Condensed:400,700', false );
wp_enqueue_style('load-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
}
add_action( 'wp_enqueue_scripts', 'HC_Scripts' );
?><?php
@harshclimate
harshclimate / archive.php
Last active Jan 13, 2018
This is a WP_Query + original loop with post thumbnail archive.
View archive.php
<?php get_header(); ?>
<article>
<div class="left">
<h3>Categories used on the website</h3>
<div class="cat-listing">
<span class="category-name">Category name</span><span class="times-used">Times used</span>
<p>
<?php
$args = array(
@harshclimate
harshclimate / archive.php
Created Jan 12, 2018 — forked from vividvilla/archive.php
Archive functions
View archive.php
// Display weekly archives
<?php wp_get_archives('type=weekly'); ?>
// Last 10 weeks archive
<?php wp_get_archives('type=weekly&limit=10'); ?>
// Monthly archive with post count
View wp-query-ref.php
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
You can’t perform that action at this time.