Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 119548

Scott Kingsley Clark on "[Plugin: Dynamic Widgets] Pods support in dynamic widgets?"

$
0
0

Oh I see now, you did a custom SQL query instead of using the API. Use the API calls given in this thread instead and it should work with Pods 2.0

For 1.x compatible code that works with 2.0, try this:

if ( function_exists( 'is_pod_page' ) ) { // Check to see if Pod Pages are activated
    if ( function_exists( 'pods_api' ) )
        $pod_pages = pods_api()->load_pages();
    else
        $pod_pages = $GLOBALS[ 'wpdb' ]->get_results( "SELECT <code>id</code>, <code>uri</code> FROM <code>&quot; . $GLOBALS[ 'wpdb' ]->prefix . &quot;pod_pages</code>", ARRAY_A );

    foreach ( $pod_pages as $pod_page ) {
        // display $pod_page[ 'name' ], Pods 1.x uses $pod_page[ 'uri' ]
        // id is $pod_page[ 'id' ]
    }
}
if ( function_exists( 'is_pod_page' ) ) {
    if ( function_exists( 'pods_api' ) )
        $api = pods_api();
    else
        $api = new PodAPI();

    $pod_page = $api->load_page( array( 'id' => $id ) );

    if ( !empty( $pod_page ) ) {
        if ( function_exists( 'pods_api' ) )
            $pod_page_name = $pod_page[ 'name' ];
        else
            $pod_page_name = $pod_page[ 'uri' ];
    }
}

Viewing all articles
Browse latest Browse all 119548

Trending Articles