• I have created a twitter sharing icon on my site. When the share dialog box appears, it’s showing the page title and url link. The page title is correct but the url is created with ?p=xxxx instead of the permalink. I checked the permalink setting and it’s set correctly to Post name. Is there a setting or coding which would use the page’s permalink instead of the WordPress generated short url? Here’s an example of the page…

    https://www.mefa.org/tips-hs-juniors-letters-recommendations/

    Thanks.
    AJ

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi AJ,

    Have you created the Twitter code yourself, is it from a plugin or a cut/paste script from Twitter?

    David.

    Thread Starter backupplan123

    (@backupplan123)

    A WordPress consultant created this for us a couple of years ago. He’s no longer reachable.

    Here are the codes that I found that he used…

    if ( ! empty( $sharelinks[‘twitter’] ) ) {
    // build the GA link
    $show .= MEFA2014_Helper::build_ga_link( array( ‘url’ => $sharelinks[‘twitter’], ‘label’ => ‘Twitter social share’, ‘cat’ => ‘Button’, ‘action’ => ‘Click’ ), ‘item-share-pop’, ‘<i class=”ss-icon ss-social-circle ss-twitter”></i>’, true );
    }

    Thanks for your help.
    AJ

    From that it looks as if the URL is being stored in $sharelinks[‘twitter’] but that code doesn’t show where it’s being defined. Can you see any other reference to this?

    David.

    Thread Starter backupplan123

    (@backupplan123)

    is this it? sorry, i’m not well versed with the codes.

    $sharelinks = MEFA2014_Helper::get_social_share_links( $post_id );

    That looks like it could be. Somewhere in your source code you must have a function named get_social_share_links – the answer lies in that function if you can find it!

    David.

    Thread Starter backupplan123

    (@backupplan123)

    I think this might be it. Not sure what I can change to use the permalink. Thanks very much for your help again. AJ

    public static function get_social_share_links( $post_id = 0, $slug = ”, $network = ” ) {

    // make sure we have a post ID or slug
    if ( empty( $post_id ) && empty( $slug ) ) {
    return;
    }

    // get my short link (if a post ID) or just the link if not
    $link = ! empty( $post_id ) ? wp_get_shortlink( $post_id ) : get_post_type_archive_link( $slug );

    // create the text to include
    if ( ! empty( $post_id ) ) {
    $text = str_replace( ‘ ‘, ‘ ‘, get_the_title( $post_id ) );
    } else {
    // fetch the object
    $object = get_post_type_object( $slug );
    // get the name portion
    $name = $object->labels->name;
    // build the text
    $text = $slug !== ‘events’ ? ‘MEFA ‘ . $name : ‘Upcoming MEFA ‘ . $name;
    }

    // spit out the facebook
    $facebook = ‘https://www.facebook.com/sharer/sharer.php?u=&#8217; . $link;
    // spit out twitter
    $twitter = ‘https://twitter.com/intent/tweet?source=webclient&via=mefatweets&text=&#8217; . esc_html( trim( $text ) ) . ‘&url=’ . urlencode( $link );
    //spit out linkedin
    $linkedin = ‘https://www.linkedin.com/shareArticle?mini=true&source=mefa&url=&#8217; . $link;
    // get the printing link
    $printlink = ‘#print’;
    // get the email share
    $emaillink = ‘#email’;
    // get the optional RSVP link
    $rsvplink = self::get_event_rsvp_link( $post_id );

    // make my array
    $sharelinks = array(
    ‘facebook’ => $facebook,
    ‘twitter’ => $twitter,
    ‘linkedin’ => $linkedin,
    ’emaillink’ => $emaillink,
    ‘printlink’ => $printlink,
    ‘rsvplink’ => $rsvplink
    );

    // send it back
    return $sharelinks;
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Twitter share dialog box is using numbered url instead of permalink’ is closed to new replies.