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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:24:00+00:00 2026-06-03T20:24:00+00:00

I am using wordpress’s advanced custom fields, which uses the syntax get_field(‘custom_field_name’); to pull

  • 0

I am using wordpress’s advanced custom fields, which uses the syntax get_field('custom_field_name'); to pull custom fields from the database. in this case, I have a series of checkboxes, and I am using PHP to see if each one has been checked, and if so, it will spit out a string. Here is my PHP:

<?php 
    if(in_array('brand-id', get_field('type_of_work') )): echo "<a href='../../work/#brand-id'>Brand ID</a> |"; endif; echo " ";

    if(in_array('print', get_field('type_of_work') )): echo "<a href='../../work/#print'>Print</a> |"; endif; echo " ";

    if(in_array('books', get_field('type_of_work') )): echo "<a href='../../work/#books'>Books</a> |"; endif; echo " ";

    if(in_array('web', get_field('type_of_work') )): echo "<a href='../../work/#web'>Web</a> |"; endif; echo " "; 

    if(in_array('packaging', get_field('type_of_work') )): echo "<a href='../../work/#packaging'>Packaging</a> |"; endif; echo " ";

    if(in_array('exhibit', get_field('type_of_work') )): echo "<a href='../../work/#exhibit'>Exhibit</a> |"; endif; 

?>

What this is doing is saying, if this checkbox is checked, then spit out a link for that checkbox. As you can see, I am echoing a “|” after each link. The problem is that the last link is followed by a “|”. I would like to remove the last “|” programmatically with PHP. Perhaps I can convert the whole thing to a string and then use substr($string, 0, -1);? Anny ideas how I would go about this?

  • 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-03T20:24:02+00:00Added an answer on June 3, 2026 at 8:24 pm
    $links = array();
    
    if(in_array('brand-id', get_field('type_of_work') )) $links[] = "<a href='../../work/#brand-id'>Brand ID</a>";
    ....
    
    echo implode(" | ",$links);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using wordpress, I am pulling in a custom fields from specific posts to fill
I am using wordpress custom fields to dynamically display a imdb link to an
I am using wordpress latest version. Currently my blog is set to custom permalink
I'm using wordpress and i have many plugins which using javascript file. I want
Using Wordpress, I need to generate an array of tags(terms) from posts in a
I am using wordpress and use custom permalink structure: /%category%/%postname%/ My problem is that
I am using Wordpress Magic Fields and have a post type with a field
I'm using WordPress plugin Category Page to display the most recent 5 posts from
I using Wordpress to display a list of thumbnails which will load a page
i using wordpress 3.1.3 to develop custom theme. it seems my theme has strange

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.