get list of ad groups/placements & ids via php
-
i am trying to populate a select list with all published ad groups and placements (and their associated IDs, assuming they have them) via something like get_posts(). I want the ID as array keys, and the title as values. Is this possible, and how might I go about it?
for reference, here’s the working code that does what I need but with single ads:
function get_all_ads(){
$args = array(
“numberposts” => -1,
“orderby” => “post_date”,
“order” => “DESC”,
‘post_type’ => array( ‘advanced_ads’ ),
“post_status” => “publish”
);
$my_posts = get_posts( $args );
if( ! empty( $my_posts ) ){
foreach ( $my_posts as $p ){
$title = $p->post_title;
$id = $p->ID;
$output[$id]= $title;
}
}
return $output;
}
- The topic ‘get list of ad groups/placements & ids via php’ is closed to new replies.