Skip to content

Instantly share code, notes, and snippets.

View chered's full-sized avatar

chered chered

View GitHub Profile
<?php $terms = get_the_terms( $post->ID , 'taxonomyname' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'taxonomyname' );
if( is_wp_error( $term_link ) )
continue;
echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}
?>
<?php if (isset($content['field_cube'])): ?>
<div class="c-field"><?php print render($content['field_cube']); ?><span class="tail-label"><?php print t('cubic feet');?></span></div>
<?php endif; ?>
In my mytheme.theme file I put the following code and I could both remove the preview button and also change the submit button text.
function mytheme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['contact_message_feedback_form', ])) {
$key = ($form_id == 'contact_message_feedback_form') ? 'actions' : 'basic';
$form[$key]['submit']['#value'] = 'My Submit Message';
$form[$key]['preview']['#access'] = FALSE;
}
}
<?php
$date = get_field('last_updated_or_reviewed', false, false);
$date = new DateTime($date);
; ?>
<p><strong>Briefsheet Updated on:</strong> <?php echo $date->format('F j, Y'); ?></p>
//functions.php
add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar for Blog', 'theme-slug' ),
'id' => 'sidebar-blog',
'description' => __( 'Widgets in this area will be shown only on blog pages.', 'theme-slug' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
<form method="get" role="search" action="https://example.com/" title="Type and press Enter to search.">
<input type="search" class="fl-search-input form-control" name="s" value="Search" onfocus="if (this.value == 'Search') { this.value = ''; }" onblur="if (this.value == '') this.value='Search';">
<input type="hidden" name="post_type" value="post"></form>
<?php $content = get_the_content();
$trimmed_content = wp_trim_words( $content, 200, '<a href="'. get_permalink() .'">...[ read more ]</a>' ); ?>
<div class="archive-trim"><?php echo $trimmed_content; ?></div>
function onboarding_remove_menu_items() {
if( !current_user_can( 'administrator' ) ):
remove_menu_page( 'edit.php?post_type=testimonial' );
endif;
}
add_action( 'admin_menu', 'onboarding_remove_menu_items' );
@chered
chered / add bank transfer method on commerce-order-invoice-view.tpl.php using if statement
Created December 3, 2014 00:22
add bank transfer method on commerce-order-invoice-view.tpl.php using if statement
<?php if($order->data['payment_method']=='bank_transfer|commerce_payment_bank_transfer'):?>
<h4><?php print t('Bank Details'); ?></h4>
<b><?php print t('Account Name:'); ?></b> <?php print t('My Website Name'); ?><br/>
<b><?php print t('Account number:'); ?></b> <?php print t('343353535'); ?><br/>
<b><?php print t('Banking institution:'); ?></b> <?php print t('BDO'); ?><br/>
<b><?php print t('Bank code:'); ?></b> <?php print t('343434'); ?><br/>