R
R
Ruslan Makarov2016-02-12 21:10:31
PHP
Ruslan Makarov, 2016-02-12 21:10:31

How to automatically assign additional field to all WordPress posts?

Good!
How to automatically assign additional a field to all WordPress posts that will contain its ID?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Khristoev, 2016-02-13
@Haoss

why not just display the post id?

N
Nikita Souvel, 2016-02-13
@Souvel1

If it’s clear on the question, then make a WP_Query request where you specify in the parameters, "post_status"=>"any"post_type here list everything you need (page, post, etc. custom, if any)
Then when you go through the received records in a loop :

$post_id = get_the_ID();
update_post_meta($post_id, 'custom_post_id', $post_id);

where custom_post_id will be your field with ID
But the person really says that this is not why, ID is so easy to get

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question