How to display custom post type title before the loop on the page as an H1 headi
-
So I have modified my Custom Post Type $title to display certain terms. See the code
add_filter('wpseo_title', 'vehicle_listing_title'); function vehicle_listing_title( $title ) { if ( is_post_type_archive('vehicles') && $id = get_queried_object_id() ) { $locations = get_query_var('location'); $location = get_term_by('slug', $locations, 'vehicle_location'); $models = get_query_var('model'); $model = get_term_by('slug', $models, 'vehicle_model'); $title = ''; if($model && $model) $title .= $model->name . ' used'; else $title .= 'Used'; $title .= ' cars for sale'; if($location && $location) $title .= ' in ' . $location->name; $title .= ' on ' . get_bloginfo('name'); return $title; } return $title; }
The code functions perfectly, but now I want to echo the exact title to show as an h1 heading in the beginning of the loop. how do I do this? I’ve tried it
get_post_meta()
, I dont think its the right function for this.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to display custom post type title before the loop on the page as an H1 headi’ is closed to new replies.