Skip to content

Instantly share code, notes, and snippets.

@cccamuseme
cccamuseme / custom-post-type-slider.php
Last active July 11, 2018 21:43
Custom post type slider
<div class="bx-wrapper">
<ul class="bxslider">
<?php
$slider = new WP_Query(array( 'post_type' => 'homepage_slider' ) );
if( $slider->have_posts() ) :
while($slider->have_posts()) :
$slider->the_post();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
@cccamuseme
cccamuseme / post-comments.php
Created November 21, 2016 20:23
echo post comments
<ol class="commentlist">
<?php
//Gather comments for a specific page/post
$comments = get_comments(array(
'post_id' => XXX,
'status' => 'approve' //Change this to the type of comments to be displayed
));
//Display the list of comments
wp_list_comments(array(
@cccamuseme
cccamuseme / http-keep-alive.txt
Created November 30, 2016 22:41
HTTP Keep Alive
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
@cccamuseme
cccamuseme / wordpress-featured-img-bg.php
Last active December 12, 2016 22:55
Use featured image as background image in WordPress
@cccamuseme
cccamuseme / exclude-vc-elements.php
Created February 6, 2017 17:14
Remove default elements in Visual Composer
// Visual Composer
// After VC Init
add_action( 'vc_after_init', 'vc_after_init_actions' );
function vc_after_init_actions() {
// Remove VC Elements
if( function_exists('vc_remove_element') ){
@cccamuseme
cccamuseme / single-project.php
Created March 3, 2017 17:34
Single Project post type template
<?php
/**
* The template for displaying all single posts.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package Mindspike
*/
get_header(); ?>
@cccamuseme
cccamuseme / homepage_posts.php
Created May 19, 2017 19:08
Change color of title based on category
<?php
// The Query
$the_query = new WP_Query( array( 'cat' => '3,4', 'posts_per_page' => 4 ) );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<h4><a href="' . get_permalink($recent["ID"]) . '">' . get_the_title() . '</a></h4>';
@cccamuseme
cccamuseme / custom-widget-area.php
Last active June 20, 2019 20:35
Custom widget area
<?php
/* New Sidebar */
function new_sidebar_widget_init() {
register_sidebar( array(
'name' => 'New Sidebar',
'id' => 'new_sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
@cccamuseme
cccamuseme / dynamic-sidebar.php
Last active June 20, 2019 20:36
Call dynamic sidebar
<?php
/* Place where you want in your theme */
<?php dynamic_sidebar( 'new_sidebar' ); ?>
?>
<?php echo do_shortcode("[shortcode]"); ?>