Skip to main content
added 2 characters in body
Source Link
user1575949
  • 153
  • 1
  • 11

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
); 
$posts = get_posts($args);

Run over each post and create multiple arraya Multiple Array of meta dataMeta Data.

$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Finally get the array's meta data I want.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
); 
$posts = get_posts($args);

Run over each post and create multiple array of meta data.

$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Finally get the array's meta data I want.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
); 
$posts = get_posts($args);

Run over each post and create a Multiple Array of Meta Data.

$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Finally get the array's meta data I want.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}
added 1 characters in body
Source Link
user1575949
  • 153
  • 1
  • 11

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
); 
$posts = get_posts($args);

Run over each post and create multiple array of meta data.

$posts = get_posts($args);
$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

AccessFinally get the array by key valuearray's meta data I want.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
);

Run over each post and create multiple array of meta data.

$posts = get_posts($args);
$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Access the array by key value.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
); 
$posts = get_posts($args);

Run over each post and create multiple array of meta data.

$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Finally get the array's meta data I want.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}
added 22 characters in body
Source Link
user1575949
  • 153
  • 1
  • 11

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts argumentsparameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
);

Run over each post and create multiple array of meta data.

$posts = get_posts($args);
$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Access the array by key value.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID in my get_posts arguments.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id)
)
);

Run over each post and create multiple array of meta data.

$posts = get_posts($args);
$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Access the array by key value.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}

This is my own solution, improvements welcome :)

Check for term ID and assign to variable.

$term_id = (has_term('activity_1','activity-tax') ? 1 : (has_term('activity_2','activity-tax') ? 2 : (has_term('activity_3','activity-tax') ? 3 : '')));

Use term ID variable in my get_posts parameters.

$args = array(
'post_type' => 'activity-post',
'order' => 'ASC',
'tax_query' => array(
    array(
    'taxonomy' => 'activity-tax', 
    'field' => 'term_id', 
    'terms' => $term_id) // Only the ID I want
)
);

Run over each post and create multiple array of meta data.

$posts = get_posts($args);
$custom_post = array();
foreach ($posts as $post) {
    $custom_post[] = get_post_custom($post->ID);
}

Access the array by key value.

foreach ( $custom_post as $key => $value ) {
    echo $value['date'][0].'<br />';
    echo $value['duration'][0].'<br />';
    echo $value['paypal'][0];
}
Source Link
user1575949
  • 153
  • 1
  • 11
Loading