• The social plugin I am using is using the defined variable: $post_link to get_permalink(); … however, this doesn’t work for my static page front page (the Facebook like button doesn’t work because of that).

    Not that code savvy, so I tried to write a PHP statement to define a function, but I don’t know if I am doing it properly or not.

    if (is_home() || is_front_page()); { $post_link = bloginfo('url'); } else { $post_link = get_permalink();

    I tried defining that… but getting an error on the website. Anyone want to suggest a solution? It would be really helpful :)!

Viewing 5 replies - 1 through 5 (of 5 total)
  • to use bloginfo in a variable, use get_bloginfo()
    http://codex.wordpress.org/Function_Reference/get_bloginfo

    Thread Starter futurepocket

    (@futurepocket)

    Tried adding that in the code, still getting a PHP error. I am wondering if the code itself is correctly written since I am not so good at PHP — just beginning to learn now 🙂 I tried to put it in here:

    $post_link = get_permalink();
    
    	$post_title = get_the_title();
    
    	if ($option['position'] == 'left' && ( !is_single() && !is_page()))
    
    		if (($source != 'manual') || ($source != 'shortcode')) 
    
    			$option['position'] = 'above';
    
    	if ($option['position'] == 'left'){
    
    		$output = '<div id="leftcontainerBox" style="' .$border. $bkcolor. 'position:' .$option['float_position']. '; top:' .$option['bottom_space']. '; left:' .$option['left_space']. ';">';
    
    		if ($option['active_buttons']['facebook_like']==true) {
    
    		$output .= '
    
    			<div class="buttons">
    
    			<iframe src="http://www.facebook.com/plugins/like.php?href=' . urlencode($post_link) . '&layout=box_count&show_faces=false&action=like&font=verdana&colorscheme=light" style="border:none; overflow:hidden; width:50px; height:65px;"></iframe>
    
    			</div>';
    
    		}

    Except, I am trying to define a function for the $post_link so if its the FRONT page, it takes the front page URL (since the $post_link variable set to just get_permalink()) is not working (doesn’t like the front page). Any ideas?

    my mistake – I stoppped checking the code after the first obvious problem 🙁

    there was one semicolon after the if () which could have been a problem, and the closing bracket } after the else section was missing;

    try:

    if (is_home() || is_front_page()) { $post_link = get_bloginfo('url'); } else { $post_link = get_permalink(); }
    Thread Starter futurepocket

    (@futurepocket)

    You did end up fixing the code, but as it turns out, I was looking for

    esc_url( wp_logout_url( $_SERVER['REQUEST_URI'] ) );

    all along, get_bloginfo(‘url’) didn’t work on the like button for some reason (maybe because its set to a static front page). Weird, anyways, the like button works fine now.

    Thread Starter futurepocket

    (@futurepocket)

    I was actually mistaken… I just can’t seem to figure it out:

    The like button on tipstosavingmoney.net (at the bottom) doesn’t like the front page (but works fine on single posts). Is this because it’s set to static posts? Is something blocking this button only from working :S.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating if is_home statement’ is closed to new replies.