Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author George Notaras

    (@gnotaras)

    Hello Craig,

    I’m afraid this is not possible to be done automatically.

    You can either enter a description manually in the relevant box in the post editing screen or programmatically customize the autogenerated description by adding some code in the functions.php file of your theme:

    function custom_auto_description( $excerpt ) {
        global $post;
        // generate a new custom description from the parts of the post you are interested in and return it
        return $custom_description;
    }
    add_filter( 'amt_get_the_excerpt', 'custom_auto_description', 10, 1 );

    Alternatively a new filter could be added which will let you programmatically set the portion of the post content you want to be used by the automatic description generator.

    George

    Plugin Author George Notaras

    (@gnotaras)

    I filed a bug report in my bug tracker to add such a filter in 2.7.2.

    Plugin Author George Notaras

    (@gnotaras)

    Hi,

    I added the ‘amt_get_the_excerpt_initial_content’ filter that can modify the initial text that is fed to the algorithm that generates the description.

    It will be available in 2.7.2

    Plugin Author George Notaras

    (@gnotaras)

    Feedback about alternative ways to resolve this is welcome.

    Thread Starter craigs85

    (@craigs85)

    Thanks George,
    I shall give it a go once the update is available. ??

    Plugin Author George Notaras

    (@gnotaras)

    Craig,

    Here is some sample code.

    function customize_auto_description_initial_data( $post_content, $post) {
        // strip H1 and Featured Section from $post_content
        return $suitable_post_content;
    }
    add_filter( 'amt_get_the_excerpt_initial_content', 'customize_auto_description_initial_data', 10, 2 );

    Hope this helps.

    Thread Starter craigs85

    (@craigs85)

    Hi George,

    Just a quick query, do I have to add the above code to my functions file?

    Plugin Author George Notaras

    (@gnotaras)

    Hello Craig,

    Yes, but this code is incomplete and is only meant to show the way to do it.

    The line:

    // strip H1 and Featured Section from $post_content

    has to be replaced by your own code that strips the H1 or any other parts of the post content you do not want the algorithm to use for the generation of the description.

    George

    How can I set the amt_get_content_description to be something that I want for a blank description. Something like as follows:

    `All of the articles that have been tagged as being related to ‘ . single_tag_title( $prefix=”, $display=false ) . ‘ available at <sitename>.’

    Need to be able to set it for both the cats and tags for my site without having to edit amt_basic.php

    Plugin Author George Notaras

    (@gnotaras)

    Hello,

    Using ‘amt_get_content_description’ is not correct, since this is only used for content pages (posts, pages, custom post types).

    Please check example 8 in the description page about how to change the generic descriptions that are used in category, tag, custom taxonomy and author archives.

    If you need more help with this, please start a new topic.

    Kind Regards,
    George

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Possible to ignore certain parts of page for description?’ is closed to new replies.