How do I make my own title?

#711655
  • Resolved Maksim
    Rank Math free

    How do I make my own title?
    Here look I add to the site news automatically from my own rss feeds and add arbitrary fields, or rather it turns out after adding a record its update.
    How to make the title update on its own unique, I am ready to prescribe it also in my feeds.
    Here is a piece of my code for an example, it would be necessary to add there a unique title, which is written manually in the admin panel.


    $post_id = wp_insert_post(array(
    'post_title' => $title,
    'post_content' => $description,
    'post_type' => 'post',
    ));
    if ($post_id) {
    $text = (string) $item->text;
    update_post_meta($post_id, 'text', $text);
    }

Viewing 1 replies (of 1 total)
  • Hello, I apologize for the inconvenience you’re facing. To automatically update the post title with a unique value, you can use the following code snippet in your functions.php or rank-math.php file:

    /**
     * Function to automatically update the post title with a unique value
     */
    function update_post_title($post_id) {
        $unique_title = 'Your Unique Title Here'; // Replace 'Your Unique Title Here' with your desired unique title
        $post_data = array(
            'ID' => $post_id,
            'post_title' => $unique_title,
        );
        wp_update_post($post_data);
    }
    add_action('save_post', 'update_post_title');

    This code will automatically update the post title with the specified unique value whenever a new post is added or an existing post is updated. If you have any further questions or need assistance with this, please feel free to ask.

    Sources:
    How to Automate the Insertion of Focus Keyword » Rank Math
    How to Fix “Either ‘name’ or ‘item.name’ should be specified” Error » Rank Math
    Why Google Displays URL Instead of Site Name in SERP? » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘How do I make my own title?’ is closed to new replies.