Title: php code into a &quot;href&quot;
Last modified: August 20, 2016

---

# php code into a "href"

 *  [Alessandro Di Ruscio](https://wordpress.org/support/users/thirdeyeblind82/)
 * (@thirdeyeblind82)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/)
 * Hi guys!
    I need to put a code like this into my template: `<a href="<?php function
   blog() { get_template_part( 'loop', 'blog' ); } ?>">`
 * I tried but on the final page nothing appears into the href…
    How can I do? Thanks!!!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196709)
 * What are you actually trying to _accomplish_?
 * * function _definitions_ belong in `functions.php`.
    * function _calls_ can go
   in template files. * `get_template_part()` is a wrapper for PHP `include()`, 
   which _includes_ an entire PHP file. * the `href` attribute expects a _URL_.
 * So, what are you trying to _do_ here? If you can explain that, we can help you
   accomplish it.
 *  Thread Starter [Alessandro Di Ruscio](https://wordpress.org/support/users/thirdeyeblind82/)
 * (@thirdeyeblind82)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196713)
 * Ok, I’m not a pro in wordpress but I’ll try to explain! 😀
 * After the click on “a” I should run just the code inside loop-blog.php.
 * Belove the same page I have this code and it works perfectly.
 *     ```
       <div id="content_post">
       <?php get_template_part( 'loop', 'blog' ); ?>
       </div>
       ```
   
 * I should do the same thing clicking on “a”.
 * I hope to have made you understand…. 🙁
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196715)
 * No, I really don’t understand.
 * Don’t speak in terms of code; speak in terms of _what’s physically happening_.
 * Clicking on a link would take the user to a different page. Are you wanting to
   specify the page to which the user is taken?
 *  Thread Starter [Alessandro Di Ruscio](https://wordpress.org/support/users/thirdeyeblind82/)
 * (@thirdeyeblind82)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196717)
 * No, clicking on “a” link should just run the code inside the file loop-blog.php
   into another page.
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196725)
 * > No, clicking on “a” link should just run the code inside the file loop-blog.
   > php into another page.
 * But _why_? Why are you trying to do that?
 * If you need to link to something, then link to it. If you need to include some
   PHP code, then include it. Why are you trying to use an HTML anchor to include
   PHP code?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘php code into a "href"’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/php-code-into-a-href/#post-2196725)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
