admin管理员组

文章数量:1135640

Ideally, the goal is to show the block number (ie: 782667) instead of the date value (ie: 26 March 2023 4:44PM CT) on all wordpress posts and pages that currently display it.

There's maybe a script we can add to the functions.php in the wordpress child-theme currently in user?

Ideally, the goal is to show the block number (ie: 782667) instead of the date value (ie: 26 March 2023 4:44PM CT) on all wordpress posts and pages that currently display it.

There's maybe a script we can add to the functions.php in the wordpress child-theme currently in user?

Share Improve this question asked Mar 27, 2023 at 14:11 SuperAticSuperAtic 1497 bronze badges 3
  • 3 What is a block number? – Jacob Peattie Commented Mar 27, 2023 at 14:56
  • do you mean post ID? There's no such thing as "block number", if it's not the posts ID you're going to have to be more specific about what it is and where it comes from – Tom J Nowell Commented Mar 27, 2023 at 16:27
  • Thanks for your responses. The blockNumber is the sequential number of a block mined in the bitcoin blockchain, every block is mined in a specific time, one every 10-15 min circa. For example, block number 783184 was mined on 2023-03-30 07:02. Ideally the function will read the post/page date and convert it at blockNumber. Not sure is clear but please let me know if you have any further questions – SuperAtic Commented Mar 30, 2023 at 13:22
Add a comment  | 

2 Answers 2

Reset to default 3

I have no idea what a 'block number' is, but when themes output the date for a post they will use either the_date() or the_time() (or both). You can replace the output using the filters the_date() or the_time():

add_filter(
    'the_date',
    function( $the_date, $format ) {
        $block_number = 'whatever a block number is';
        
        return $block_number;
    },
    10,
    2
);

We ended up building Bitcoin Block Date Converter, a plugin for WordPress and compatible with the majority of themes using this for

$ date -ud "1/1/2017"
Sun Jan 1 00:00:00 UTC 2017
$ date -ud "1/1/2017" +%s
1483228800

+add three zeroes to that number and append it to a blockchain.com URL:

https://www.blockchain.com/btc/blocks/1483228800000

And there you have it the block number:

446033 (Main Chain) 2017-01-01 00:02:33

For more info:

Repo on GitHub

Demo web site

Donate on Geyser

.

本文标签: functionsHow to display *block number* instead *date value* on Wordpress posts