$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Get meta values from parent post and save in child post|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Get meta values from parent post and save in child post

matteradmin10PV0评论

I have a custom post type "E-Books" with two categories "E-Book Title" and "Chapter Page", and custom meta boxes (table of contents, etc).

The E-Book post type uses one page template, and displays content based on category conditional.

<?php if (in_category('e-book-title')) { content } ?>

The "E-Book Title" posts are the parents and all meta info will be stored on these posts.

The "Chapter Page" posts are children of their respective "E-Book Title", and I would like each chapter page to grab the meta values of their parent.

For example, the table of contents meta will be stored for the title page "Book One", and when a new chapter post "Chapter One" is created with the assigned parent "Book One", the meta values from "Book One" will be stored for the new chapter post.

Is there a way to do this? I could manually enter the meta values in the chapter posts, but would be much user friendly if the chapter posts inherited their parents meta automatically.

Post a comment

comment list (0)

  1. No comments so far