[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog
  • #
  • &
  • A
  • B
  • C
  • D
  • E
  • F
  • G
  • H
  • I
  • J
  • L
  • M
  • N
  • O
  • P
  • Q
  • R
  • S
  • T
  • U
  • V
  • W
  • [

Show a single image link to a page using bw_thumbs or bw_images

Say you’ve got a single post, page or Custom Post Type (CPT) and you want to display an image with a link to it in a sidebar widget. How do you do it?

HTML method

If you know HTML then it’s very easy to do it for one image.
  • Add a new text widget to the sidebar.
  • Use the image tag to display the image: <img>
<img src="http://www.oik-plugins.com/wp-content/uploads/2012/12/rounding-the-bassin-du-thau-lighthouse.jpg/>
  • Wrap it in an anchor tag for the link: <a>
Using the post ID <a href="http://www.oik-plugins.com/?p=6436>image tag goes here</a> OR using the permalink <a href="http://www.oik-plugins.com/2012/12/show-a-single-image-link-to-a-page-using-bw_thumbs-or-bw_images/">image tag goes here</a> And that’s fine. Until you want to change the image or the target of the link. BUT wouldn’t it be easier to use a shortcode?

oik shortcode and custom image link URL

Using the oik custom image link URL and a shortcode we can reduce the amount of typing you need to do. The [bw_thumbs] or [bw_images] shortcodes can be used to display attached images and the oik custom image link URL can be used to route the viewer to the target. Here we display the attachment(s) to the page.
[bw_thumbs post_type=attachment post_parent=6436]

rounding-the-bassin-du-thau-lighthouse

[bw_images post_type=attachment post_parent=6436]

rounding-the-bassin-du-thau-lighthouse

Linking directly to the post or page

If you can find a way of narrowing down the query on the post, page or CPT so that only one post, page or CPT is listed, then the attached image will automatically link to the target. This is fairly easy if displaying a page which is a single child of another page. BUT it’s (currently) a bit trickier if there is potentially more than one item listed in the results. [bw_posts post_type=post include=6436 exclude=-1]
  • Show a single image link to a page using bw_thumbs or bw_images
[bw_thumbs post_type=post include=6436 exclude=-1]
Show a single image link to a page using bw_thumbs or bw_images
[bw_images post_type=post include=6436 exclude=-1] What’s needed is the ability to define the target post ID. AND that’s coming soon, in the next version of the oik base plugin.

Published: December 17, 2012 | Last updated: December 4, 2020

Filed Under: News, oik

Information

Component:

Recent plugin updates

oik-weight-zone-shipping v0.2.6 oik-weight-zone-shipping v0.2.6 has been tested with WooCommerce 7.4.0. ...
sb-chart-block v1.2.3 SB Chart Block v1.2.3 contains a fix for an Uncaught Error: Call to undefined function bw_trace2()  ...
SB Chart Block v1.2.1 Update to SB Chart Block v1.2.0 for custom colors, font size options and multiple y-axis charts.  ...
oik-css v2.1.0 Update to oik-css v2.1.0 for the ability to style CSS and GeSHi output in documentation. ...
oik-types v2.3.0 Update to oik-types v2.3.0 for improved control over sort order on archives ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: oikplug@oik-plugins.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.1.1. PHP: 7.4.33. Memory limit: 768M