Skip to content

Instantly share code, notes, and snippets.

@ajithrn
ajithrn / gravity-forms_bootstrap.css
Last active March 1, 2017 14:36 — forked from DevinWalker/gravity-forms_bootstrap
Wordpress: GForm Bootstrap
/* ------------------------------------
Gravity Forms
---------------------------------------*/
.gform_wrapper ul { padding-left: 0; list-style: none }
.gform_wrapper li { margin-bottom: 15px }
.gform_wrapper form { margin-bottom: 0 }
@ajithrn
ajithrn / short_content.php
Last active August 29, 2015 13:56
Wordpress: short_content
<?php
/**
* short_content generator
* @param string $mycontent content string
* @param string $after
* @param int $length
* @return string
*/
function short_content( $mycontent, $after = '', $length ) {
@ajithrn
ajithrn / acf-repeater-loop.php
Last active April 12, 2018 11:51
Wordpress: acf repeater loop
<?php
/** Functions available
* have_rows()
* has_sub_field()
* get_sub_field()
* the_sub_field()
*/
?>
<?php if( have_rows( 'repeater_field_name' ) ): ?>
@ajithrn
ajithrn / breadcrumbs.php
Created February 22, 2014 08:48
Wordpress: breadcrumbs
<?php
/**
* only works in pages, no categories support
* */
echo '<ul>';
if ( is_page() && $post->post_parent ): // checking if the page has parent
$parent_id = $post->post_parent;
$breadcrumbs = array();
@ajithrn
ajithrn / acf-option-page.php
Last active August 29, 2015 13:56
Wordpress: acf option page customization
<?php
/**
* ======== acf option page customization ========
* @param [type] $settings
* @return [type]
*/
function my_acf_options_page_settings( $settings )
{
$settings['title'] = 'Page Title';
$settings['menu'] = 'Menu Title';
@ajithrn
ajithrn / wp-query.php
Last active August 29, 2015 13:56
Wordpress: wp query
<?php
/** Wordpress general query
* http://codex.wordpress.org/Class_Reference/WP_Query
* */
// WP_Query arguments
$custom_args = array ( 'post_type' => 'custom_post', 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => '5', 'order' => 'DESC', 'orderby' => 'date', );
// The Query
$custom_query = new WP_Query( $custom_args );
@ajithrn
ajithrn / prepend-www
Created February 25, 2014 16:09
htaccess: prepend www
#add www.infront of urls
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+\.[a-z]{2,6})$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
@ajithrn
ajithrn / top-parent-id.php
Last active August 29, 2015 13:57
Wprdpress: Top Parent page id
<?php
if ($post->post_parent) :
$ancestors = get_post_ancestors($post->ID); //get all parent post ids in an array
$root = count($ancestors)-1; //find the count
$parent = $ancestors[$root]; //get top parent id
else:
@ajithrn
ajithrn / custom-taxonomy-list.php
Last active June 14, 2019 13:08
Wordpress: list custom taxonomy
<?php
/**
* list taxonomy accoeding to the custom post type
* @var [string]
* ref: http://codex.wordpress.org/Template_Tags/wp_list_categories
*/
$custom_taxonomy = get_object_taxonomies('taxonomy-slud-or-id');
if(count($custom_taxonomy) > 0):
@ajithrn
ajithrn / custom-archive-page.php
Created March 26, 2014 15:21
Wordpress: custom taxonomy archive customization
<?php
//Define the function for customize archive page
function your_taxonomy_archive_customization ( $query ) {
if (($query->is_main_query()) && (is_tax('your_custon_taxonomy'))) {
$query->set( 'posts_per_page', '3' );
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}