• Resolved iriteser

    (@iriteser)


    Hi Kolja

    thanks for this VERY helpful plugin!

    I want to use it to add the (in Germany mostly necessary) “[Werbung]” (advertisment) to my posts.

    Question: I have round about 3000 blog posts. Is it possible to set a default value so all are changed in once?

    Thanks in advance
    Irit

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter iriteser

    (@iriteser)

    oh, second question: how to manage the subtitle in a new line?

    Plugin Author thaikolja

    (@thaikolja)

    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.
    Thread Starter iriteser

    (@iriteser)

    Hi Kolja

    thanks very much for your answers! I will play around with your code. And of course I make an backup before ??

    LG Irit

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Default for second title possible?’ is closed to new replies.