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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:21:27+00:00 2026-06-01T21:21:27+00:00

What I want to do is output a custom field content (which is a

  • 0

What I want to do is output a custom field content (which is a button with a dynamic link that’s being inserted in the value of the custom field of each posts) right after the_content and before the plugins.

This is the code for the custom field:

<div class="button">
  <a href="<?php echo get_post_meta($post->ID, 'Button', true); ?>">
    <img src="<?php echo get_template_directory_uri() . '/images/button.png'; ?>" alt="link" />
  </a>
</div>

On wordpress codex I also found this example of how to apply a filter to the_content in order to obtain something similar to what I want. This is the code:

add_filter( 'the_content', 'my_the_content_filter', 20 );
function my_the_content_filter( $content ) {
if ( is_single() )
    // Add image to the beginning of each page
    $content = sprintf(
        '<img class="post-icon" src="%s/images/post_icon.png" alt="Post icon" title=""/>%s',
        get_bloginfo( 'stylesheet_directory' ),
        $content
    );
// Returns the content.
return $content;
}

The problem is I don’t know PHP and I have no idea how am I supposed to edit the above code to apply on my specific case.

I modified it a bit and I manage to list the button, but only before the_content and without the PHP that enables the custom field.

add_filter( 'the_content', 'my_the_content_filter', 20 );
function my_the_content_filter( $content ) {

if ( is_single() )
    // Add button to the end of each page
    $content = sprintf(
        '<img class="button-link" src="%s/images/button.png" alt="Link" title=""/>%s',
        get_bloginfo( 'stylesheet_directory' ),
        $content
    );
// Returns the content.
return $content;
}

You can see the output here: http://digitalmediaboard.com/?p=6583 (it’s the top-right ‘show-me’ button)

  • 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-01T21:21:28+00:00Added an answer on June 1, 2026 at 9:21 pm
    $content .= sprintf(...); // will add the button right after content.
    

    In your example

    // Add button to the end of each page
    $content = sprintf(
        '<img class="button-link" src="%s/images/button.png" alt="Link" title=""/>%s',
        get_bloginfo( 'stylesheet_directory' ),
        $content
    );
    

    change it to

    $lnk=get_bloginfo( 'stylesheet_directory' );
    $content .= '<img class="button-link" src=$lnk."/images/button.png" alt="Link" title=""/>';
    

    to add new content/button right after content. Also you need to add some css style for that button to be placed according to your desired need within/after content.

    I think you can easily edit the index.php and can add the code you’ve provided with your question right after content.

    Update:

    add_filter( 'the_content', 'my_the_content_filter', 20 );
    function my_the_content_filter( $content ) {
        if ( is_single() )
        {
            global $post;
            $imgLnk=get_bloginfo( 'stylesheet_directory' );
            $pgLnk=get_post_meta($post->ID, 'Button', true);
            $content .= '<a href="'.$pgLnk.'"><img class="button-link" src=$lnk."/images/button.png" alt="Link" title=""/></a>';
        }
        return $content;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view which lists some nodes and I want a custom output
I have a custom tag in Jinja2 that I want to output something only
I have a a form that I want to output as custom HTML. My
I want to output the function name each time it is called, I can
I want to output the value of a double in it's full precision. However,
I have a custom content (using cck) namely thewittyshit and it has a field
I have a class that I need to do some custom XML output from,
Basically I want to create a custom handler to unserialize a db field called
I have a huge query that is being made dynamically, but I want the
So I want to make a java application which, while running, can run custom

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.