Setting page title for Entries
It is possible to set individual titles for the Single Entry page in a View by using the pre_get_document_title WordPress filter.
The code example below should be placed on your theme's
functions.php
file.
Here's the most basic example, where the page title is set to the value of Field ID 1 for the View with ID 8:
add_filter( 'pre_get_document_title', 'gv_seo_title', 999, 1 ); function gv_seo_title( $title ) { if ( ! function_exists( 'gravityview' ) ) { return $title; // Return original title } if ( ! $entry = gravityview()->request->is_entry() ) { return $title; // Return original title } if ( ! $view = gravityview()->request->is_view() ) { return $title; // Return original title } if ( $view->ID != 8 ) { // Specify the View ID here return $title; // Return original title } $title = rgar($entry, '1'); // We pull the title from the Field ID 1 return $title; }
For entries that are embedded with the [gventry] shortcode the page title can be set on the host page as needed.