Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8702027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:32:54+00:00 2026-06-13T02:32:54+00:00

I have a foreach statement that looks like the following: foreach ($term[‘terms’] as $term_single)

  • 0

I have a foreach statement that looks like the following:

foreach ($term['terms'] as $term_single) {
    $term_object = get_term_by('name', $term_single, $tax_name);

    switch ($term['tax_name']) {
        case has_action( "basey_taxonomy_search_teaser_{$tax_name}" ) :
            do_action( "basey_taxonomy_search_teaser_{$tax_name}",$term_object, $term_single );
        break;

        default:
            echo basey_taxonomy_search_teaser_default($term_object,$term_single);
        break;
    }
}

So, within this, I have both the $term_object and $term_single variables to pass to the basey_taxonomy_search_teasr_default() function. The odd thing here is, if I do the following in another location:

function basey_taxonomy_search_teaser_default($term_object,$term_single) {

    ob_start();

    do_action('basey_taxonomy_teaser_before');
    echo '<article id="tax-' . $term_object->term_id . '" class="' . $term_object->taxonomy . '">';
    echo '<a href="';
    echo get_term_link($term_object);
    echo '">';
    echo $term_single;
    echo '</a>';
    echo '</article>';
    do_action('basey_taxonomy_teaser_after');

    $display = apply_filters('basey_taxonomy_teaser_default_view', ob_get_clean());
    return $display;
}

it works just fine on my localhost, but online at a server, it is coming back with errors for $term_object and $term_single as undefined. If I want the function definition to use the values from the initial call, is there a better way to do so? Again little confused on why it would work here on localhost (MAMP) but on the server, it would error out. Aside from it being a php.ini issue (which I think this is more fundamental programming practice), looking to see what I’m doing wrong and if my assumptions are off on passing values via a function. Thanks!

Update

var_dump($term_object) right after $term_object = get_term_by('name', $term_single, $tax_name);:

localhost gives me:

object(stdClass)#181 (10) { ["term_id"]=> string(3) "127" ["name"]=> string(4) "Base" ["slug"]=> string(4) "base" ["term_group"]=> string(1) "0" ["term_order"]=> string(1) "0" ["term_taxonomy_id"]=> string(3) "130" ["taxonomy"]=> string(18) "profile_categories" ["description"]=> string(4) "Base" ["parent"]=> string(1) "0" ["count"]=> string(1) "2" }

live server gives me:

bool(false)

Bah, quite frustrating.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:32:55+00:00Added an answer on June 13, 2026 at 2:32 am

    I’d guess that the DB you’re hitting is different and the $term_single is null, leading to a null $term_object, and when you call the function and try to use the objects that’s where you’re dying.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an INSERT statement that looks like this: INSERT INTO officer (officer_number, name,
I have a table that looks like the following: ID Key Value Order 1
I have a for each statement that looks for a Taxonomy by ID and
I have code that looks like this: var ds = new DataSet(); var fooIDToFoo
I have an array, $data, that looks like this when printed: [1] => Array
I have an Oracle table with data that looks like this: ID BATCH STATUS
I have a user a object that looks like this. $user = new User();
So I have a multi-dimensional array looks like this. $config = array( First Name
I have a select statement that gathers data from one monthly-summary table like the
In my program I have currently a piece of code that looks like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.