Skip Navigation

[Resolved] Custom post statuses and icons

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create custom post statuses. I would also like to show custom icons on the front-end of the site that visually represent each post status.

Solution: Toolset does not currently provide the ability to create custom post statuses, so custom code or another plugin will be required.

You can use Bootstrap's glyphicons and conditional HTML to display different icons based on the post status. Here's an example:

[wpv-conditional if="( '[wpv-post-status]' eq 'pending' )"]
  <span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-status]' eq 'draft' )"]
  <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
[/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://getbootstrap.com/docs/3.3/components/#glyphicons-how-to-use

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by sinisaB 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#617387
Conditional delete link.png
Post statuses.png

Hello!

Is there any easy feature to add "New custom post statuses" for custom posts?
Also I need somehow to mark more visually post statuses on every custom post layout on the frontend (textual, by graphic icon or similar)? Please give me some suggestion how can I add in layouts visual mark for post status...
Another question, I need that "Delete" link be visible only for pending status, so how to put a conditional output for such option in my view table?
Thanks in advance for an answer,
Sinisa

#618001
Screen Shot 2018-02-20 at 12.29.46 PM.png

Hello, I will answer your questions here. In the future, please create separate tickets for each question, to help keep things organized in the forums. Thanks!

Is there any easy feature to add "New custom post statuses" for custom posts?
Toolset does not offer this feature, so another plugin or custom code will be required.

Also I need somehow to mark more visually post statuses on every custom post layout on the frontend (textual, by graphic icon or similar)? Please give me some suggestion how can I add in layouts visual mark for post status...
You can use the shortcode wpv-post-status to add a specific CSS class to some HTML element, and target that class to set a different background image. Something like this in the HTML tab of a Visual Editor cell:

Post status: <div class="status status-[wpv-post-status]"></div>

Then in CSS:

.status {
  height: 100px;
  width: 100px;
}
.status.status-publish {
  background-image: 'path/to/publish-image.png';
}
.status.status-pending {
  background-image: 'path/to/pending-image.png';
}
.status.status-draft {
  background-image: 'path/to/draft-image.png';
}

Another question, I need that "Delete" link be visible only for pending status, so how to put a conditional output for such option in my view table?
You can use the "conditional output" button to build this conditional code. In the popup, choose "Views shortcodes" and select wpv-post-status. Type "pending" in the value field. See the screenshot.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#618255

Hello Christian,

thanks on your clear answers! It seems very easy with your help... 🙂
I put conditional output for "delete" link, it's working now...
CSS also...
I will find a solution for custom post statuses somewhere else...

Thank You,
Sinisa

P.S. Ok, I will create separate tickets in future for different subjects. Sorry!

#618263

Sorry one question more...

How code should looks if I use Bootstrap glyphs for visual marking of statuses from: hidden link
I don't have a clue how to implement them instead CSS and my own images, as you mentioned.
Do I need to use conditional output in that case?
Thanks,
Sinisa

#618272

Yes, you can use conditional HTML to display different glyphs based on the post status. You can find a glyph example here:
hidden link

Here is an example of two glyphs in conditionals:

[wpv-conditional if="( '[wpv-post-status]' eq 'pending' )"]
  <span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-status]' eq 'draft' )"]
  <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
[/wpv-conditional]
#618396
Solved.JPG

Hi,

Thank You my Guru... ?
Now everything fits and looks easy...

All the best,
Sinisa

#618597

Deleted