WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
[resolved] Add Post Title as First Keyword Automatically? (8 posts)

  1. meanstreak
    Member
    Posted 10 months ago #

    I am trying to somewhat automate my SEO. The dynamic keyword function does not work on my All in One SEO plug in. I would like to have the post title automatically be the first keyword for each posting.

    Does anyone know where and what file I might be able to insert <?php the_title(); ?> into the All in One SEO code to make this happen? I have searched all the files and made several attempts with no luck.

    Thanks for the help!

    http://wordpress.org/plugins/all-in-one-seo-pack/

  2. meanstreak
    Member
    Posted 10 months ago #

    I think it could be located here. I have tried several test with no success.

    /all-in-one-seo-pack/aioseop_class.php

    ( isset( $keywords ) && $togglekeywords == 0 && !empty( $keywords ) && !( is_home() && is_paged() ) ) {
    if ( isset( $meta_string ) ) $meta_string .= "\n";
    $keywords = str_replace( '"', '', $keywords );
    $meta_string .= sprintf( "<meta name=\"keywords\"the_title, \"%s\" />\n", $keywords );

  3. Peter Baylies
    Member
    Plugin Author

    Posted 10 months ago #

    meanstreak,

    Add this code to the functions.php of your theme or into a plugin:

    add_filter( 'aioseop_keywords', 'meanstreak_add_title_to_keywords' );
    
    function meanstreak_add_title_to_keywords( $keywords ) {
    	global $post;
    	if ( !empty( $post ) ) {
    		if ( empty( $keywords ) )
    			$keywords = $post->post_title;
    		else
    			$keywords = $post->post_title . ", " . $keywords;
    	}
    	return $keywords;
    }
  4. meanstreak
    Member
    Posted 10 months ago #

    Thanks for the help. I tried the code in both Wp function AIONSEO function like you mentioned. I changed meanstreak to my theme name twentytwelve.

    Upon removing the code from the function file(s), the site keeps timing out with a 500 server error.

    I replace the edited files with backups, but the site still will not connect. Did this code add anything to the database?

    Thanks again for taking the time to respond!

  5. Peter Baylies
    Member
    Plugin Author

    Posted 10 months ago #

    meanstreak,

    If you change the name of the function, make sure you change it in both places - in the add_filter() call and in the function name. This code doesn't add anything to the database, removing it should reverse whatever effects it has.

  6. meanstreak
    Member
    Posted 10 months ago #

    Thanks for the quick reply. I'm not sure what I did wrong. this is the error code that I am receiving when I edit both files.

    Fatal error: Cannot redeclare twentytwelve_add_title_to_keywords() (previously declared in /wp-content/plugins/all-in-one-seo-pack/aioseop_functions.php:519) in /wp-content/themes/twentytwelve/functions.php on line 499

    If i just edit one file (function.php or aioseo_functions.php), the site times out. I will do a restore of the server files to return the site to its original state, unless you might have any additional suggestions.

    Thanks for all your help!

  7. Peter Baylies
    Member
    Plugin Author

    Posted 10 months ago #

    meanstreak,

    It looks like you have this function declared in two places; remove it from either location, provided that it is the same function and not a different function with the same name (that's why I prefaced my function with meanstreak rather than with twentytwelve).

  8. meanstreak
    Member
    Posted 10 months ago #

    Makes sense. Thanks again for the help!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.