Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Unable to set Custom “Link URL” for Featured Image, and More?

I cleaned up the code u have given and it should work as you intend.

Let me know if your still having problems.

<div id="slider">
<?php
    $c = get_option('wpns_category');
    $n = get_option('wpns_slices');
    $s = new WP_Query( array( 'cat' => $c, 'posts_per_page' => $n ) );
    if( $s->have_posts() ): while( $s->have_posts() ): $s->the_post(); global $post;
?>
        <?php if(has_post_thumbnail()){ ?>
            <a href="https://wordpress.stackexchange.com/questions/33600/<?php echo get_post_meta($post->ID,"slider-url", true); ?>" title="<?php the_title(); ?>">
                <?php the_post_thumbnail(); ?>
            </a>
        <?php } ?>
    <?php endwhile; endif;?>
</div>

Related Posts:

  1. Change post thumbnail using front end post edit form
  2. Function to replace the url of featured images in the wordpress database?
  3. Programmatically set thumbnail via URL using DOM and XPATH – Where to add ELSEIF
  4. How do you code a featured image into an XML as a jpg link, instead of using a data-id number?
  5. wp_get_attachment_metadata()[‘image_meta’] fetch WP metadata or EXIF?
  6. Copy wp_postmeta from one database to another
  7. How do I set a featured image (thumbnail) by image URL when using wp_insert_post()?
  8. How do I get image url only on the_post_thumbnail
  9. How to get image title/alt attribute?
  10. How to Fix HTTP Error When Uploading Images?
  11. Add class name to post thumbnail
  12. How to disable WordPress from creating thumbnails?
  13. How to retrieve image from URL and set as featured image/post thumbnail
  14. Programmatically get images by URL and save in uploads folder
  15. How to set featured image to custom post from outside programmatically
  16. How do you remove hard coded thumbnail image dimensions?
  17. How do you get the post thumbnail size?
  18. Setting a post’s featured image from an embedded YouTube video
  19. How to get featured image’s width and use elsewhere in template?
  20. set_post_thumbnail_size vs add_image_size
  21. Minimum Dimensions Requirement for Featured Image?
  22. Generate Thumbnails only for Featured Images
  23. How to get all featured image sizes and their URLs?
  24. How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
  25. How to add post featured image to RSS item tag?
  26. How do I regenerate thumbnails?
  27. Display thumbnail only if requested size exists
  28. Delete original image – keep thumbnail?
  29. How to add category to: ‘wp-admin/post-new.php’?
  30. the_post_thumbnail responsive srcset not populating with custom image size
  31. Set custom name for generated thumbnails
  32. Post thumbnail alt title
  33. Get Featured Image via direct sql query
  34. Get featured image on Blog Index
  35. the_post_thumbnail hard cropping not working no matter what
  36. Can I refresh the thumbnails programmatically?
  37. How to add multiple image sizes of the same size with add_image_size
  38. New image size version only for the Featured Image file
  39. wp_get_attachment_image_src always returns full-sized image
  40. Get featured image URL by page id
  41. change set_post_thumbnail_size according to post type admin page
  42. Add Title Attribute to WordPress Image the_post_thumbnail
  43. Can’t extract and set SVG dimensions
  44. Set Featured Image Front Frontend Form
  45. Getting Thumbnail Path rather than Image Tag
  46. Display Category Thumbnail and links in Woo commerce
  47. the_post_thumbnail with lazyload JQ plugin
  48. Replacing Gutenberg Featured Image control?
  49. Display Post Thumbnail Without Being Featured Image
  50. Featured Image of Video from oembed
  51. oEmbed, thumbnails and wordpress
  52. wp_get_attachment_image_src() and custom sizes
  53. Prevent WordPress from cropping GIF files
  54. media_sideload_image generates blank?
  55. Post thumbnail outside the loop
  56. What’s the difference between post thumbnails and featured images (if any)?
  57. Getting custom-sized featured image’s URL?
  58. What is your take: TimThumb vs. WordPress Thumbnails? The great debate [closed]
  59. How to crop thumbnail height to auto with set width
  60. Retrieve 1st image in post and set it as featured image, when post is saved/updated
  61. Use thumbnail image using url of that image
  62. Retrieve featured image as object
  63. How do I add the featured image to the_content after the first paragraph?
  64. Showing a placeholder/default img, if no featured image is set
  65. Re-order media links?
  66. Multiple featured image thumbnails for post types (Multiple Post Thumbnails plugin)
  67. the_post_thumbnail scaling not hard cropping
  68. Skip posts without a thumbnail in loop
  69. wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); Getting thumb from wrong loop
  70. Set featured image for multiple posts
  71. Image uploader with “Set Featured Image” link on front end
  72. adding an id to the_post_thumbnail
  73. Featured image size in ADMIN panel?
  74. Featured image with the same height thumbs returns wrong thumb
  75. How can I display my featured image correctly inside my single posts?
  76. How to change the naming of the resized image files
  77. Featured image upload finished hook
  78. How to get featured post title & image using JSON API?
  79. Generate thumbnail for images with the same size as thumbnails
  80. Set post thumbnail as background
  81. Display thumbnail only on the very first post in the loop?
  82. How to show featured image CAPTION only if it exist
  83. Set post-thumbnail (with php)?
  84. get_thumbnail_id returns full size image
  85. Implementing Zurb’s Interchange Into WordPress
  86. can the_excerpt function also get images?
  87. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  88. How to get_posts having post thumbnail?
  89. Add Image Dimensions to Media Library Tab on Media Upoader
  90. Change Output for Images in Content
  91. Add options to featured image
  92. Featured Image Inherited from Parent Page
  93. Change wording of default thumbnail metabox
  94. Specific featured image for each category
  95. how to pull images with no add_theme_support(‘post_thumbnails’)
  96. Can WordPress crop only the post thumbnails?
  97. Allow user to manually set crop area of default/custom image sizes on upload [closed]
  98. Add post title as alt tag for featured image
  99. get_pages – Display child then grandchild pages
  100. How to replace the_post_thumbnail template tag and show the first inside the post image instead
Categories post-thumbnails Tags post-meta, post-thumbnails, urls
WordPress Categories: Function using custom SQL to return array of specific category IDs
Custom Post Type, Pagination and 404s?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress