• Resolved shokks

    (@shokks)


    Watched both the videos multiple times:
    https://www.youtube.com/watch?v=y0UkzQFk5Ok
    https://www.youtube.com/watch?v=0gvT6Myt1Ck

    However, not being able to make virtual post work – gives me 404. Somehow it is not able to find the slug values in the table. ‘slug’ is a column name in Airtable Table – no capitalization problem (checked 10000 times!!).

    Pretty sure its something super stupid! ??

    Virtual Post Config

    URL Pattern to match: ^/(.*)/?
    Test Url : (blank)
    “This test URL matches 0 records in table Pitch”
    Filter by Formula: {slug} = ‘$1’
    Sort results: (blank)
    Airtable Table Name: Pitch
    Airtable Field to be used as post_name: {slug}
    Airtable Field to be used as post_title: {slug}
    Map to this page: airpress-single-template

    Logfile excerpt:

    Pitch Config VirtualPost	^/(.*)/? matched
    DELAYED QUERY : /Pitch : 535538a4f920e8c70678f53d2743ac00	Pitch?filterByFormula={slug} = ''
    Simulated Virtual Post Collection
    #########################################
    AirpressCollection Object
    (
        [query] => AirpressQuery Object
            (
                [runtime_start:AirpressQuery:private] => 1535924158.8043
                [config:AirpressQuery:private] => Array
                    (
                        [name] => Pitch Table Configuration
                        [api_key] => key1234
                        [app_id] => app1234
                        [api_url] => https://api.airtable.com/v0/
                        [refresh] => 60
                        [expire] => 86400
                        [fresh] => fresh
                        [debug] => 1
                        [log] => /home/lorem/www/ipsum.com/wp-content/plugins/airpress/airpress.log
                        [id] => 0
                    )
    
                [parameters:AirpressQuery:private] => Array
                    (
                        [filterByFormula] => {slug} = ''
                        [fields] => Array
                            (
                            )
    
                    )
    
                [properties:AirpressQuery:private] => Array
                    (
                        [table] => Pitch
                    )
    
                [relatedQueries:AirpressQuery:private] => 
                [errors:AirpressQuery:private] => 
            )
    
        [index:AirpressCollection:private] => Array
            (
            )
    
        [storage:ArrayObject:private] => Array
            (
            )
    
    )
    
    #########################################
    
    stash_and_trigger_deferred_queries|Sending ASYNC request to process 1 deferred queries.
    
    AIRPRESS LOADED
    
    AIRPRESS LOADED
    run_deferred_queries|Processing 1 queries
    200	0	0.48	Pitch?filterByFormula={slug} = ''
    run_deferred_queries|Query Pitch?filterByFormula={slug} = '' had 0 records returned. Que Bella!
    stash_and_trigger_deferred_queries|DONE in 0.81519103050232 seconds
    
    • This topic was modified 6 years, 6 months ago by shokks.
    • This topic was modified 6 years, 6 months ago by shokks.
Viewing 1 replies (of 1 total)
  • Plugin Author Chester McLaughlin

    (@chetmac)

    It would appear that you’re attempting to use VirtualPosts on the “home page” of your WordPress site. That isn’t currently supported. you’ll notice in your debug output that your slug is empty because you’re matching the entire URL and yet you’re only access “/” …

    If you need to load Airtable data on your homepage, you’ll need to dive into the PHP and add something like this to your theme functions file:

    
    <?php
    
    function my_airpress_homepage_query( $atts ){
    	global $post;
    
    	if ( is_home() ){
    
    		$my_airpress_connection_id_or_name = 0;
    
    		$query = new AirpressQuery("My Table Name", $my_airpress_connection_id_or_name);
    		
    		// Optionally specify View
    		$query->view("My View");
    
    		// Optionally specify Fields (will only return these fields)
    		$query->fields(["Name","Gem Type","Jewel Type","Quick Pics","Good Pics","Certificates"]);
    
    		// Optionally provide a filterByFormula, this one ensures Slug is NOT empty
    		$query->filterByFormula("NOT({Slug},'')");
    
    		// This will ensure that you can use shortcodes on the homepage still
    		// such as [apr field="Slug"]
    		$post->AirpressCollection = new AirpressCollection($query);
    	}
    
    }
    
    add_action("the_post", "my_airpress_homepage_query");
    
    ?>
    
Viewing 1 replies (of 1 total)
  • The topic ‘Virtual Post setup issue (Virtual fields work perfectly)’ is closed to new replies.