Skip to content

Instantly share code, notes, and snippets.

View chered's full-sized avatar

chered chered

View GitHub Profile
<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>
//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">',
<?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>
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 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; ?>
<?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
global $wp_query;
$total_results = $wp_query->found_posts;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
?>
Found <?php echo $total_results ;?> Results
Page <?php echo $paged; ?> of <?php echo $wp_query->max_num_pages; ?><br />
function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('post','page'));
}
return $query;
}
add_filter('pre_get_posts','searchfilter');
add_action("load-post-new.php", 'block_post');
function block_post()
{
if($_GET["post_type"] == "physician" || "posts" )
wp_redirect("edit.php?post_type=physician");
}