WordPress.org

Support

Support » How-To and Troubleshooting » Make widget content clickable

Make widget content clickable

  • oneruffryder
    Member

    @oneruffryder

    Hi , all ! I m hoping that i m on the right place.So to be short for the start,things are like this.I bought a theme and theme´s autor doesnt offer any support.I have modified already a lot of stuff on this theme,but on the last thing i hit a dead end.I m newbie at this and php is not so familiar to me,as i am more “trial & error” guy for wordpress.

    So on the top of this site is a scoreboard inside which i manually enter scores.What i want is to make all of this scores clickable so on click they would open a proper link for that post.

    I need to edit a widget file and add a link code around several DIVs.I guess but i dont know how.I have a separate widget for this scoreboard but some coding for it is inside theme function as well.

    If is it necessary to add this widget file please let me know.Thanks

Viewing 15 replies - 1 through 15 (of 17 total)
  • J M
    Participant

    @hiphopinenglish

    Looking at your source code, the div that you need to make clickable is

    <div class="score-teams">
    Lyon<br />
    Montp
    </div><!--score-teams-->

    Exactly how to that is difficult (impossible) to say without seeing some of your code. Could you show the widget code you have?

    oneruffryder
    Member

    @oneruffryder

    i dont know is it ok to add it here,due to some rules..as i said i m new.I have tried to sent a code to your inbox,but cant find it 😀

    This is somesite which i find to upload code,so here it is – view

    oneruffryder
    Member

    @oneruffryder

    And i forgot to add from themefunction 2 parts..first to register this and the second one – view

    oneruffryder
    Member

    @oneruffryder

    Link is gone when i re-edited post so themefunction code is here

    J M
    Participant

    @hiphopinenglish

    OK, explain exactly what you want each team or score to link to.

    oneruffryder
    Member

    @oneruffryder

    Well i have the option to add scores manually which is the only option to add it.So when i add it i want to have another texarea there to add a link.So any scores which i enter will point to any link which i add inside.

    (i manage to do add this,and to enter link,but the score was not clickable,i guess i needed to add more functions,but thats is something i dont know )

    I think thats much easier then the 2nd option that scores link automatically,because on that way i would have to change a much more.

    If i m not clear,let me know.thanks

    J M
    Participant

    @hiphopinenglish

    I would try, in your Custom Post Type code, adding

    array(
    
                'name' => 'Home Team Link',
    
                'desc' => 'Enter home team link (profile or page)',
    
                'id' => $prefix . 'home_team_link',
    
                'type' => 'text',
    
    	    'std' => ' 0'
    
            )
    
    	array(
    
                'name' => 'Away Team Link',
    
                'desc' => 'Enter away team link (profile or page)',
    
                'id' => $prefix . 'away_team_link',
    
                'type' => 'text',
    
    	    'std' => ' 0'
    
            )	
    
        )

    on line 179 (approx.) after your other array entries which create your Meta Boxes.

    Then, in your Plugin code on line 147 onwards, it should be like this:

    <div class="score-teams">
                    <a>ID, "away_team_link", true); ?>"><?php echo get_post_meta($post->ID, "gd_away_team", true); ?></a>
                    <a>ID, "home_team_link", true); ?>"><?php echo get_post_meta($post->ID, "gd_home_team", true); ?></a>
                  </div><!--score-teams-->
                  <div class="score-right">
                    <a>ID, "away_team_link", true); ?>"><?php echo get_post_meta($post->ID, "gd_away_team", true); ?></a>
                    <a>ID, "home_team_link", true); ?>"><?php echo get_post_meta($post->ID, "gd_home_team", true); ?></a>
                  </div><!--score-right-->

    You may wish to also add an alt attribute to make things nicer.

    Let me know if that works.

    oneruffryder
    Member

    @oneruffryder

    Ok i will try ASAP…but i m not sure i understand where to add the first part of code ? Custom Post Type code ? is this inside theme function and the second one inside scoreboard.php ?

    oneruffryder
    Member

    @oneruffryder

    I got it…but when i tried to add and save the first page i got this

    “Parse error: syntax error, unexpected T_ARRAY, expecting ‘)’ .. functions.php on line 604

    J M
    Participant

    @hiphopinenglish

    Sorry, the first code goes in your theme’s functions file.

    J M
    Participant

    @hiphopinenglish

    Yeah, apologies, I missed some commas.

    Your functions (from line 100 to the end of the section) should look like this:

    Pastebin

    oneruffryder
    Member

    @oneruffryder

    Yes i got it.The first one i m adding to theme function but it gives this error.On line 604 which comes exactly on the second part of code array(

    J M
    Participant

    @hiphopinenglish

    Which line? (Paste the new code on Pastebin)

    oneruffryder
    Member

    @oneruffryder

    Ok,i replaced and doesnt show any errors.Still you can see on the homepage how it looks like .Still doesnt work.

    I notice you wrote a code with home team and away linking.Is that necessary ? Because i thought to build so the home & away team with score would be basically one link or link inside div ..any idea what could i try also ? thank you

    J M
    Participant

    @hiphopinenglish

    We’ve made a mistake somewhere. Hmmm… yes, that would be better. I had understood that you wanted to link to a team’s profile, rather than a match post containing updates.

    If I’ve understood correctly now, can you change the first bit yourself (remove one of the two arrays we added in step one, and rename the other match_page or something)?

    The second would need to have just that echo statement in an atag covering lines 72 and 73, and then again covering 76 and 77.

    I can probably write that in the morning if you can’t do it yourself.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Make widget content clickable’ is closed to new replies.