Last active
August 29, 2015 14:05
-
-
Save thewebprincess/e5f7410072fcd9dc2968 to your computer and use it in GitHub Desktop.
The building blocks for using Gravity Forms to build an online petition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ADDING CUSTOM POST TYPE | |
add_action('init', 'all_custom_post_types'); | |
function all_custom_post_types() { | |
$types = array( | |
// Pledge Items | |
array('the_type' => 'pledge', | |
'single' => 'Pledge', | |
'plural' => 'Pledges')); | |
foreach ($types as $type) { | |
$the_type = $type['the_type']; | |
$single = $type['single']; | |
$plural = $type['plural']; | |
$labels = array( | |
'name' => _x($plural, 'post type general name'), | |
'singular_name' => _x($single, 'post type singular name'), | |
'add_new' => _x('Add New', $single), | |
'add_new_item' => __('Add New '. $single), | |
'edit_item' => __('Edit '.$single), | |
'new_item' => __('New '.$single), | |
'view_item' => __('View '.$single), | |
'search_items' => __('Search '.$plural), | |
'not_found' => __('No '.$plural.' found'), | |
'not_found_in_trash' => __('No '.$plural.' found in Trash'), | |
'parent_item_colon' => '' | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'has_archive' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'menu_position' => 5, | |
'supports' => array('title','editor','thumbnail','custom-fields','excerpt')); | |
register_post_type($the_type, $args); | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<div class="block"> | |
<ol reversed="reversed" class="pledge-item"> | |
<?php | |
$args = array( 'post_type' => 'pledge', 'posts_per_page' => 100 ); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
/* with sprintf() you make a “pattern" first using %s and some other possible symbols then you define them with php functions/variables */ | |
printf( '<li>%s,&nbsp;%s,&nbsp;%s,&nbsp;%s,&nbsp;%s</li>', | |
get_the_title(), | |
get_post_meta($post->ID, 'age', true), | |
get_post_meta($post->ID, 'city', true), | |
get_post_meta($post->ID, 'state', true), | |
get_post_meta($post->ID, 'country', true) | |
); | |
endwhile; | |
?> | |
</ol> | |
</div> | |
<!–end block–> | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment