• Resolved dlwilliams

    (@dlwilliams)


    I set up virtual posts and it’s working great. The one question I have, however, is that the page title is always the name of the template page. How can I change it so the page title changes for each record I send to it (using a slug field in my airtable base)? For example, the page is https://domain.com/restaurants/eat-at-joes/ and I want the page title to be “Eat at Joe’s” instead of “Restaurant Template”. Is there a way to do that with the Virtual Posts option?

    Thanks! Loving this plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chester McLaughlin

    (@chetmac)

    With the latest version of the plugin, yes!

    You can also use braces to specify two fields for the post_title. For example, you can reference other (non-array) fields like this:

    Airtable Field to be used as post_title: {Name} – {Status}

    Also you can use the airpress_virtualpost_setup action in your functions.php file like this:
    (untested, sorry! Let me know if it doesn’t work and I’ll test)

    function my_virtualpost_setup($config){
    	global $post;
    
    	if ( ! is_airpress_empty($post->AirpressCollection) ){
    														// Field name 		// related table name
    		$post->AirpressCollection->populateRelatedField("Good Options For:", "Special Diets");
    
    		// Assuming a single record returned:
    		$record = $post->AirpressCollection[0];
    
    		$good_for = $record["Good Options for:"]->getFieldValues("Diet");
    
    		$post->post_title = $record["Name"]." - ".implode(",", $good_for);
    	}
    
    }
    add_action('airpress_virtualpost_setup','my_virtualpost_setup');
    Thread Starter dlwilliams

    (@dlwilliams)

    Fantastic! Thanks so much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Distinct Page Titles on Virtual Posts’ is closed to new replies.