Skip to content

Instantly share code, notes, and snippets.

View vajrasar's full-sized avatar

Vajrasar Goswami vajrasar

View GitHub Profile
@vajrasar
vajrasar / cpt_archive.php
Created October 1, 2013 10:09
Simple Way: Using genesis_custom_loop() for Custom Post Archive.
<?php
/*
Create archive-<cpt name>.php file and put the following code in it
*/
/**
* Template Name: Classifieds Archive
* Description: Used as a page template to show Classifieds archive
*/
<?php //don't include this php tag while pasting snippet in your functions.php file
//to catch & print first image occuring in post content (the_content) via famous 'catch-that-image'
/* we could have also used genesis_get_image() to catch the first image instead of 'catch_that_image' script;
but genesis_get_image() was actually catching "first uploaded image" instead of "first image occuring in the_content".
*/
add_action('genesis_entry_header','image_above_t',7); //to place image above title
@vajrasar
vajrasar / related_posts_via_tags.php
Last active December 25, 2015 01:49
Related posts with Fb Like and Tweet button.
<?php //do not include this php tag
add_action ('genesis_after_entry', 'my_custom_loop_func');
function my_custom_loop_func() {
if(is_home())
{
global $wp_query;
if( 2 == $wp_query->current_post ) {
<?php //do not include this php tag
add_filter( 'genesis_post_title_output', 'modified_classi_p_title');
function modified_classi_p_title($title) {
global $post;
$customcat = '<span id="cat_classi">' . get_the_term_list($post->ID, 'classi_cat') . '</span>';
$title = $customcat . $title;
return $title;
@vajrasar
vajrasar / custom
Created November 28, 2013 10:28
problem
<?php
/******
* Template Name: Events Archive
* Description: Used as a page template to show Events archive
*********/
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_do_event_loop');
@vajrasar
vajrasar / custom
Created November 28, 2013 10:34
problem0
<?php
/********
* Template Name: Events Archive
* Description: Used as a page template to show Events archive
*******/
remove_action('genesis_loop', 'genesis_do_loop');
add_action( 'genesis_loop', 'custom_do_events_loop' );
@vajrasar
vajrasar / cpt.php
Created November 28, 2013 13:04
probques
<?php
/*****Creating CPT and Taxos for Events [START]******************/
function my_custom_post_events() {
$labels = array(
'name' => _x( 'Events', 'post type general name' ),
'singular_name' => _x( 'Event', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Event' ),
@vajrasar
vajrasar / problem
Last active December 30, 2015 21:49
The Template for Tag Taxonomy Archive
<?php
/**
* Template Name: Event's Tag Taxonomy Archive
* Description: Used as a page template to show Tag Taxonomy Archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_loop_two' ); // Add custom loop
@vajrasar
vajrasar / evnt-date-logic.php
Last active January 1, 2016 14:39
logic to metaquery
<?php
/*
front page archive
**/
//Other necessary code here
if ( have_posts() ) :
while ( have_posts() ) : the_post();