From: Laury GvR Date: Wed, 15 May 2019 23:31:31 +0000 (-0400) Subject: Add custom template tag file, search remain local on homepage instead of site-search X-Git-Tag: v1.0.5^2~16 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=090192b53e307a865d69884cd87114b6005f68a8;p=WP-Themes%2Fuptravel.git Add custom template tag file, search remain local on homepage instead of site-search --- diff --git a/functions.php b/functions.php index 6aa2d54..aaaf006 100644 --- a/functions.php +++ b/functions.php @@ -458,14 +458,14 @@ function SearchFilter($query) { } add_filter('pre_get_posts','SearchFilter'); -// Exclude pages from search queries -function exclude_pages_search_when_logged_in($query) { - if ( $query->is_search ) - $query->set( 'post__not_in', array( 22,24,26,28 ) ); +// // Exclude pages from search queries +// function exclude_pages_search_when_logged_in($query) { +// if ( $query->is_search ) +// $query->set( 'post__not_in', array( 22,24,26,28 ) ); - return $query; -} -add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_in' ); +// return $query; +// } +// add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_in' ); /* function change_wp_search_size($query) { @@ -484,10 +484,10 @@ function display_memberfindme_directory() { $_REQUEST['textSearch'] = $_REQUEST['s']; $_REQUEST['action'] = 'list'; $_REQUEST['event_name'] = $_REQUEST['s']; - echo do_shortcode('[glm-members-list view="list" text-search="'.stripslashes($_REQUEST['s']).'"]'); + echo do_shortcode('[glm-members-list view="list" show="-search-filters-opened" text-search="'.stripslashes($_REQUEST['s']).'"]'); if( isset($_REQUEST['event_name']) && !empty($_REQUEST['event_name'])){ echo do_shortcode('[glm-members-event-list limit="10"]'); - echo 'View All Events'; + echo 'View All Events'; } // $my_postid = 30722;//This is page id or post id // $content_post = get_post($my_postid); @@ -495,4 +495,22 @@ function display_memberfindme_directory() { // $content = apply_filters('the_content', $content); // $content = str_replace(']]>', ']]>', $content); // echo $content; -} \ No newline at end of file +} + + +/** + * Custom template tags for this theme. + */ +require get_template_directory() . '/lib/template-tags.php'; + +/* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ +add_theme_support( 'html5', array( + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', +) ); \ No newline at end of file diff --git a/lib/template-tags.php b/lib/template-tags.php new file mode 100644 index 0000000..12b755f --- /dev/null +++ b/lib/template-tags.php @@ -0,0 +1,123 @@ +%2$s'; + if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { + $time_string = ''; + } + + $time_string = sprintf( $time_string, + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ), + esc_attr( get_the_modified_date( 'c' ) ), + esc_html( get_the_modified_date() ) + ); + + $posted_on = sprintf( + esc_html_x( 'Posted on %s', 'post date', 'uptravel' ), + '' . $time_string . '' + ); + + // Not showing "by " anymore +// $byline = sprintf( +// esc_html_x( 'by %s', 'post author', 'uptravel' ), +// '' . esc_html( get_the_author() ) . '' +// ); + + echo '' . $posted_on . ''; // WPCS: XSS OK. + +} +endif; + + +if ( ! function_exists( 'uptravel_entry_footer' ) ) : +/** + * Prints HTML with meta information for the categories, tags and comments. + */ +function uptravel_entry_footer() { + // Hide category and tag text for pages. + if ( 'post' === get_post_type() ) { + /* translators: used between list items, there is a space after the comma */ + $categories_list = get_the_category_list( esc_html__( ', ', 'uptravel' ) ); + if ( $categories_list && uptravel_categorized_blog() ) { + printf( '', $categories_list ); // WPCS: XSS OK. + } + + /* translators: used between list items, there is a space after the comma */ + // $tags_list = get_the_tag_list( '', esc_html__( ', ', 'uptravel' ) ); + // if ( $tags_list ) { + // printf( '', $tags_list ); // WPCS: XSS OK. + // } + } +/* + if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo ''; + comments_popup_link( esc_html__( 'Leave a comment', 'uptravel' ), esc_html__( '1 Comment', 'uptravel' ), esc_html__( '% Comments', 'uptravel' ) ); + echo ''; + } +*/ +// edit_post_link( +// sprintf( +// /* translators: %s: Name of current post */ +// esc_html__( 'Edit %s', 'uptravel' ), +// the_title( '"', '"', false ) +// ), +// '', +// '' +// ); +} +endif; + +/** + * Returns true if a blog has more than 1 category. + * + * @return bool + */ +function uptravel_categorized_blog() { + if ( false === ( $all_the_cool_cats = get_transient( 'uptravel_categories' ) ) ) { + // Create an array of all the categories that are attached to posts. + $all_the_cool_cats = get_categories( array( + 'fields' => 'ids', + 'hide_empty' => 1, + // We only need to know if there is more than one category. + 'number' => 2, + ) ); + + // Count the number of categories that are attached to the posts. + $all_the_cool_cats = count( $all_the_cool_cats ); + + set_transient( 'uptravel_categories', $all_the_cool_cats ); + } + + if ( $all_the_cool_cats > 1 ) { + // This blog has more than 1 category so uptravel_categorized_blog should return true. + return true; + } else { + // This blog has only 1 category so uptravel_categorized_blog should return false. + return false; + } +} + +/** + * Flush out the transients used in uptravel_categorized_blog. + */ +function uptravel_category_transient_flusher() { + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + return; + } + // Like, beat it. Dig? + delete_transient( 'uptravel_categories' ); +} +add_action( 'edit_category', 'uptravel_category_transient_flusher' ); +add_action( 'save_post', 'uptravel_category_transient_flusher' ); diff --git a/parts/content-none.php b/parts/content-none.php index 78d2292..96ed5d5 100644 --- a/parts/content-none.php +++ b/parts/content-none.php @@ -4,7 +4,7 @@ * * @link https://codex.wordpress.org/Template_Hierarchy * - * @package wmta + * @package uptravel */ ?> @@ -20,16 +20,16 @@ -

+

-

Search Results for: ' . get_search_query() . '' ); ?>

+

Search Results for: ' . get_search_query() . '' ); ?>

-

+

@@ -22,7 +22,7 @@ @@ -31,7 +31,7 @@
- +

diff --git a/sections/footer.php b/sections/footer.php index 5165e40..f9990ce 100644 --- a/sections/footer.php +++ b/sections/footer.php @@ -158,11 +158,11 @@ $cities = $decode_array['cities']; myEl.addEventListener('click', function() { var search_url = '' - + '/site-search' - + '/?s=' + encodeURI(document.getElementById('tag').value) + '&glm_action=list' - + '&categorySearch=' + encodeURI(document.getElementById('lbl').value) - + '&cityUserSearch[]=' + encodeURI(document.getElementById('xlo').value) - + '®ionUserSearch[]=' + encodeURI(document.getElementById('xre').value); + //+ "/site-search" + + "/?s=" + encodeURI(document.getElementById('tag').value) + '&glm_action=list' + + "&categorySearch=" + encodeURI(document.getElementById('lbl').value) + + "&cityUserSearch[]=" + encodeURI(document.getElementById('xlo').value) + + "®ionUserSearch[]=" + encodeURI(document.getElementById('xre').value); window.location = search_url; //console.log(search_url); }, false); diff --git a/sections/search.php b/sections/search.php index 580f464..8e89d9c 100644 --- a/sections/search.php +++ b/sections/search.php @@ -4,10 +4,10 @@
- +

Please enter a query in the search box.


get_search_query() returned empty.
- +

Search Results for ""

@@ -29,31 +29,31 @@ - + - + endif; ?>