• Resolved Leslie P

    (@lesstx)


    I know this may seem odd, but is there a way to create a shortcode that will link to just one entry rather than an entire category?

    I’d like to be able to show the title and description and image and all of that, but just for one target.

    And then, if I need to change something, I change it in the SL listing and the change is reflected on all pages and posts that reference it.

    I really hope it’s possible and I’ve just missed the magical shortcode option for it.

    https://www.ads-software.com/plugins/simple-links/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hi Leslie,

    You could either assign this link to a second category which is used only for this link. Then use that second category in the shortcode.

    Otherwise you could add this to your active theme’s functions.php file

    add_filter( 'simple_links_parsed_query_args', 'sl_one_link', 9, 2 );
    function sl_one_link( $q, $o ){
    	if( !empty( $o->args[ 'one_link' ] ) ){
    		$q[ 'p' ] = $o->args[ 'one_link' ];
    	}
    	return $q;
    }

    Then in your shortcode you could specify which link you want to show by adding a custom “one_link” attribute with the link’s id like so

    [simple-links one_link="635"]

    Thread Starter Leslie P

    (@lesstx)

    Wow! Excellent, and many many thanks!

    The “one item in a category” idea had occurred to me this morning as I made coffee. (I guess by the end of the day yesterday my brain was mostly mush)

    I’m gonna give the custom code a shot, because it will make me feel special to have custom code from the author, but the fallback to a one-item category is a great solution as well.

    Thanks again. This is a great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create Link to just one entry’ is closed to new replies.