Hi @iriteser,
Please excuse the late reply.
how to manage the subtitle in a new line?
You can do this by adding <br>
to the title format.
Question: I have round about 3000 blog posts. Is it possible to set a default value so all are changed in once?
Not by default, but you could loop through all posts and then set it programmatically. Here’s an example:
<?php
/** Array to store updated posts for results */
$updated = [];
/** Get all posts */
$posts = get_posts(
[
"post_type" => "post", // The post type you'd like to change
"showposts" => -1 // To loop through ALL posts
]
);
/** Only run if Secondary Title is active */
if(function_exists("get_secondary_title")) {
/** Loop through all posts */
foreach($posts as $post) {
$secondary_title = get_secondary_title($post->ID);
/** Skip this post if it already has a secondary title (and is longer than 3 characters) */
if(strlen($secondary_title) >= 3) {
continue;
/** Add // before "continue" if you want to disable the skipping */
}
$updated[] = update_post_meta(
$post->ID,
"_secondary_title",
"[Werbung] "
);
}
/** Display results */
echo count($updated) . " posts have been updated.";
}
I didn’t test this. Do not run this code snippet without adjusting it to your needs and don’t forget to make a database backup before.
-
This reply was modified 5 years, 4 months ago by thaikolja.