tomusborne / wp-show-posts

Other
14 stars 11 forks source link

Disable link for title #9

Open tomusborne opened 7 years ago

tomusborne commented 7 years ago

Make it so you can disable the title link with a filter.

alexseboe commented 7 years ago

can you add a filter to disable all links? Image, title and abstract? Maybe assign attributes to the filter filter_removelinks(image, title, abstract)

tomusborne commented 6 years ago

This gets a little weird as the link is within the_title() function.

Instead, we can just turn the title off, and then add in a link-less title:

add_action( 'wpsp_before_header', 'tu_add_linkless_title' );
function tu_add_linkless_title( $settings ) {
    if ( 10 == $settings['list_id'] ) {
        the_title();
    }
}
addisonhall commented 6 years ago

If you want to disable ALL links within a wp-show-posts list, I've come up with this: https://gist.github.com/addisonhall/a9d6756de4835018e6ac80a2531e754a

It's far from perfect, but it gets the job done until we have a checkbox. ;-)

UPDATE: I've fixed the link. Sorry about that.

tomusborne commented 6 years ago

As of 1.1, you'll be able to do this:

add_filter( 'wpsp_disable_image_link', 'tu_disable_links', 10, 2 );
add_filter( 'wpsp_disable_title_link', 'tu_disable_links', 10, 2 );
function tu_disable_links( $output, $settings ) {
    if ( 177 === $settings['list_id'] ) {
        return true;
    }

    return $output;
}

177 being the ID of the list we're targeting.

You can grab beta.1 here: https://tomusborne.com/dev/temp/wp-show-posts.zip

Hoping to get it released tomorrow, so any quick testing is appreciated! :)

addisonhall commented 6 years ago

FYI, the new disable link filters work for me!