-
Author
-
December 14, 2015 at 14:19 #93123MatthiasParticipant
Hi,
I’m trying to create a shortcode for a follow button, I’m almost done but I still get an error when pasting to functions.php:
// Add Shortcode
function follow_shortcode() {
$output ‘<div class=”um-followers-user-btn”>’;
if ( $user_id1 == get_current_user_id() ) {
echo ‘<a href=”‘ . um_edit_profile_url() . ‘” class=”um-follow-edit um-button um-alt”>’ . __(‘Edit profile’,’um-followers’) . ‘</a>’;
} else {
echo $um_followers->api->follow_button( $user_id1, get_current_user_id() );
}
$output'</div>’;
}
add_shortcode( ‘followBtn’, ‘follow_shortcode’ );
Could you please take a minute to help me out on this ? I’m almost done but stuck.
Thanks
December 14, 2015 at 17:19 #93158sharmstrModeratorYou code syntax is wrong.
You should be doing “$output =” for both div lines and for the two lines that have echos. Then at the end you echo out $output
COPY CODEecho $output;
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
December 14, 2015 at 17:31 #93160MatthiasParticipantThank you very much for your help.
I have this which still creates an error:COPY CODEfunction follow_shortcode() { $output = "<div class="um-followers-user-btn"> if ( $user_id1 == get_current_user_id() ) { echo '<a href="' . um_edit_profile_url() . '" class="um-follow-edit um-button um-alt">' . __('Edit profile','um-followers') . '</a>'; } else { echo $um_followers->api->follow_button( $user_id1, get_current_user_id() ); } </div>"; echo $output; } add_shortcode( 'followBtn', 'follow_shortcode' );
I followed what you said but it’s not working … Where did I go wrong ? Thanks for your help
December 14, 2015 at 17:34 #93162sharmstrModeratorYou didnt replace the 2 echo like I’ve instructed
COPY CODEfunction follow_shortcode() { $output = '<div class="um-followers-user-btn">'; if ( $user_id1 == get_current_user_id() ) { $output .= '<a href="' . um_edit_profile_url() . '">' . __('Edit profile','um-followers') . '</a>'; } else { $output .= $um_followers->api->follow_button( $user_id1, get_current_user_id() ); } $ouptput .= '</div>'; echo $output; } add_shortcode( 'followBtn', 'follow_shortcode' );
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
December 14, 2015 at 20:17 #93226sharmstrModeratorDid that work?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.