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 8636579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:15:47+00:00 2026-06-12T10:15:47+00:00

I have an array as follows <?php $args = array( post_author_url => no, thumbnail_custom_field

  • 0

I have an array as follows

<?php
$args = array(
"post_author_url" => "no",
"thumbnail_custom_field" => "image",
"post_include" => get_user_meta($userID, 'member_owner', true),
"layout_mode" => "multi_column","layout_num_cols" => "3");
special_recent_posts($args);
?>

This works great, but I want to have a Condition on one of the items

"thumbnail_custom_field" => "image",

The "image" might not exist so I need a fall back so it displays OK.

for example:

<?php if ( get_post_meta($post->ID, 'image', true)) {
echo 'image'
} else { 
echo 'image-fallback'
?>

How can I have the image tag in the array set as a result of this IF statement? Do I make it a string before the array? or do I put the IF statement directly into the array? looking for a bit of expert guidance..thanks

  • 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-12T10:15:49+00:00Added an answer on June 12, 2026 at 10:15 am

    Try the following:

    <?php
    $args = array(
    "post_author_url" => "no",
    "thumbnail_custom_field" => ((get_post_meta($post->ID, 'image', true))?'image':'image-fallback'),
    "post_include" => get_user_meta($userID, 'member_owner', true),
    "layout_mode" => "multi_column","layout_num_cols" => "3");
    special_recent_posts($args);
    ?>
    

    The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE. Lookup “Ternary Operator”.

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

Sidebar

Related Questions

I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have two arrays in PHP as follows: People: Array ( [0] => 3
I have have an array as follows: $row when I output the entire array
I have a double array as follows: $values[$ids][$dates] So for each $id I have
Background I have an array of objects (Users) defined and set as follows: //
My problem is as follows. I have an array of objects in the form
For development of web services, i have to make multilevel Associative array as follows
I have a template method as follows:- template<typename T, int length> void ProcessArray(T array[length])
I have a row-major iterator to a 2D array, with derefence operator as follows:
I have an array as follows array(2) { [operator] => array(2) { [qty] =>

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.