Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need HTML / PHP converted into Echo WordPress

  • SOLVED

Hi again!

I need the following code in Box 1 re-formatted to work inside the the code in Box 2.

The code in box 1 displays terms, images etc and I want this code to show INSTEAD of the <em><strong>. $term->name .</strong></em> list in Box 2. I want to KEEP the filtering of fields in place in Box 2.

<strong>Box 1</strong>

<div class="col-lg-3">
<?php $termlink = get_term_link( $lc->slug, 'focus15' ); ?>
<div class="panel panel-default">
<div class="panel-image">

<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-info"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4>

</div>

<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field('taximage', 'focus15_'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
else { ?>
<img class="img-responsive" src="http://www.MYSITE.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>

<!-- Get Image by Attachment ID End-->

</div>
<div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a>
</div>
</div>
</div>


Box 2

<?php

$terms = get_terms('focus15', array(

'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list
'hide_empty' => 0 ) );

if($terms)

{
echo '<ul>';

foreach($terms as $term)

{
if( get_field('group_active_in_focus_15', 'focus15_'.$term->term_id) != 'active15' )

continue;

echo '<li>' . $term->name . '</a></li>';
}
echo '</ul>';
}
?>

Answers (3)

2014-08-26

Fahad Murtaza answers:

Box two code should be like this

<?php



$terms = get_terms('focus15', array(



'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list

'hide_empty' => 0 ) );



if($terms)



{

echo '<ul>';



foreach($terms as $term)



{

if( get_field('group_active_in_focus_15', 'focus15_'.$term->term_id) != 'active15' )



continue;



echo '<li>' . list_term_info($lc). '</a></li>';

}

echo '</ul>';

}

?>


and just put the top box 1 code in a function called list_term_info($lc)

Gist: https://gist.github.com/fahdi/ee1b8cefef1dc6159f11


streetfire comments:

Thank you for trying to help me, wish we could have gotten this to work as well.

2014-08-26

Sébastien | French WordpressDesigner answers:

<?php
$terms = get_terms('focus15', array(
'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list
'hide_empty' => 0 ) );

if($terms)
{
echo '<ul>';
foreach($terms as $lc)
{
if( get_field('group_active_in_focus_15', 'focus15_'.$lc->term_id) != 'active15' )
continue;
echo '<li>'; ?>
<div class="col-lg-3">
<?php $termlink = get_term_link( $lc->slug, 'focus15' ); ?>
<div class="panel panel-default">
<div class="panel-image">

<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-info"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4>

</div>

<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field('taximage', 'focus15_'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
else { ?>
<img class="img-responsive" src="http://www.MYSITE.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>

<!-- Get Image by Attachment ID End-->

</div>
<div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a>
</div>
</div>
</div>
<?php
echo '</a></li>';
}
echo '</ul>';
}
?>


streetfire comments:

This would work, but I don't need the content in the list <ul> <li>'s


Sébastien | French WordpressDesigner comments:

ok, so just use this code :

<?php

$terms = get_terms('focus15', array(

'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list

'hide_empty' => 0 ) );



if($terms)

{



foreach($terms as $lc)

{

if( get_field('group_active_in_focus_15', 'focus15_'.$lc->term_id) != 'active15' )

continue; ?>

<div class="col-lg-3">

<?php $termlink = get_term_link( $lc->slug, 'focus15' ); ?>

<div class="panel panel-default">

<div class="panel-image">



<div class="thumbnail">

<div class="caption">

<br/><br/>

<h1><span class="label label-info"><?php echo $lc->count ?></span></h1>

<p> Symbols </p>

<h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4>



</div>



<!-- Get Image by Attachment ID Start-->

<?php

$attachment_id = get_field('taximage', 'focus15_'.$lc->term_id);

if ($attachment_id) {

$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');

if ($image) {

?>

<img class="img-responsive" src="<?php echo $image[0]; ?>" />

<?php

}

}

else { ?>

<img class="img-responsive" src="http://www.MYSITE.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />

<?php } ?>

</div>



<!-- Get Image by Attachment ID End-->



</div>

<div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a>

</div>

</div>

</div>

<?php



}



}

?>


Sébastien | French WordpressDesigner comments:

the same code, well laid out
<?php
$terms = get_terms('focus15', array(
'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list
'hide_empty' => 0 ) );

if($terms) {
foreach($terms as $lc) {
if( get_field('group_active_in_focus_15', 'focus15_'.$lc->term_id) != 'active15' ) continue; ?>
<div class="col-lg-3">
<?php $termlink = get_term_link( $lc->slug, 'focus15' ); ?>
<div class="panel panel-default">
<div class="panel-image">

<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-info"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4>
</div>

<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field('taximage', 'focus15_'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php
}
}
else { ?>
<img class="img-responsive" src="http://www.MYSITE.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>
<!-- Get Image by Attachment ID End-->

</div>
<div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a></div>
</div>
</div>
<?php
}
}
?>


streetfire comments:

Thank you! This works!

2014-08-26

Arnav Joy answers:

please try this

<?php



$terms = get_terms('focus15', array(



'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list

'hide_empty' => 0 ) );



if($terms)



{

echo '<ul>';



foreach($terms as $term)



{

if( get_field('group_active_in_focus_15', 'focus15_'.$term->term_id) != 'active15' )



continue;



echo '<li>';?>

<div class="col-lg-3">

<?php $termlink = get_term_link( $lc->slug, 'focus15' ); ?>

<div class="panel panel-default">

<div class="panel-image">



<div class="thumbnail">

<div class="caption">

<br/><br/>

<h1><span class="label label-info"><?php echo $lc->count ?></span></h1>

<p> Symbols </p>

<h4> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </h4>



</div>



<!-- Get Image by Attachment ID Start-->

<?php

$attachment_id = get_field('taximage', 'focus15_'.$lc->term_id);

if ($attachment_id) {

$image = wp_get_attachment_image_src($attachment_id, 'industrygroup-img');

if ($image) {

?>

<img class="img-responsive" src="<?php echo $image[0]; ?>" />

<?php

}

}

else { ?>

<img class="img-responsive" src="http://www.MYSITE.com/wp-content/uploads/2014/08/RA-logo-300px-groups.jpg" alt="<?php the_title(); ?>" />

<?php } ?>

</div>



<!-- Get Image by Attachment ID End-->



</div>

<div class="panel-footer text-center"><a href="<?php echo $termlink; ?>"><?php echo $lc->name; ?></a>

</div>

</div>

</div>
<?php echo '</li>';

}

echo '</ul>';

}

?>