• Resolved ed4becky

    (@ed4becky)


    I am having some trouble getting my shortcode to pass a parameter.

    In my page I put:

    [rootsPersona personId=’p111′ /]

    My shortcode handler code is:

    function rootsPersonaHandler( $atts, $content = null ) {
    	$rootsPersonId = $atts["personId"];
    	$block = "rootsPersonaHandler: $rootsPersonId";
    	if(isset($rootsPersonId)) {
    	// this block never gets called
    	}
    	return $block;
    }

    However, $rootsPersonId is always coming up as unset. “rootsPersonaHandler:” is all that ever gets passed.

    Can anyone else see the issue? I’m stuck.

    Thanks
    Ed

Viewing 5 replies - 1 through 5 (of 5 total)
  • Just a guess but don’t you need to do an add_shortcode somewhere?

    add_shortcode( 'rootsPersona', 'rootsPersonaHandler' );

    Related:
    Shortcode_API

    Thread Starter ed4becky

    (@ed4becky)

    Yes, I left all the admin/setup stuff out.

    The handler is getting called, in that I see “rootsPersonaHandler:” in my output. $rootsPersonId = $atts[“personId”]; just always comes up empty.

    It the case thing. This works:

    function rootspersonahandler( $atts, $content = null ) {
    	$rootspersonid = $atts["personid"];
    	$block = "rootsPersonaHandler: $rootspersonid";
    	if(isset($rootspersonid)) {
    	// this block never gets called
    	}
    	return $block;
    }
    add_shortcode( 'rootspersona', 'rootspersonahandler' );
    Thread Starter ed4becky

    (@ed4becky)

    DOH!

    Yep, that was it. Thank you.

    Actually just need to fix this:

    $rootsPersonId = $atts["personid"];

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shortcode problem’ is closed to new replies.