-1

I want to execute a function in a specific page only, that edits the post title of posts inside a post-grid plugin.

I tried:

if (is_page('my-slug')) { add_filter(...); } //page slug

if (is_page('12345')) { add_filter(...); } //page ID

add_filter('the_title', 'title_with_attributes', 10, 2);
function title_with_attributes($title, $id) {
    if (is_page('12345') || is_page('my-slug')) { 
        //Do stuff ...
    }
}

With no results. The function is the following and runs fine.

function title_with_attributes($title, $id) {
    global $wp_query;
    if(get_post_type($post->ID)=="product"){
        global $post;
        //get other variables from post here ...
        $title = "add text and vars ".$title;
    }
    return $title;
}

Maybe there is a way to add this function when the plugin runs but I do not know how. The plugin is the "Post-Grid" from WP Bakery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.