Lucas
Forum Replies Created
-
Forum: Plugins
In reply to: [JSON API] External controllers in a plugin (Error)I found a solution but it is indeed ugly (IMHO)
You have to set a path relative to the plugin itself.
That means that you cannot use a “absolute” (http://) or another path.So instead of having this:
return plugins_url( 'hello.php' , __FILE__ );You got to have this:
return "../wp-content/plugins/api-extend/hello.php";@dphiffer – is there any way possible that I can use the standard absolute path through my plugin?
A constant that needs to be changed or?I fixed it using this code instead.
Just if anyone finds this thread and wonders how it is done this is how to do it:
First we make a function (in functions.php) called featured which will create a custom WP_Query.
function featured(){ $featured = new WP_Query( 'posts_per_page=1' ); if ( $featured->have_posts() ) { while ( $featured->have_posts() ) : $featured->the_post(); get_template_part( 'content', get_post_format() ); endwhile; } } add_action('tdm_before_header','featured');Now I have created a hook using this function:
function tdm_before_header() { do_action('tdm_before_header'); }…and calls it from the theme using the function itself (note: excerpt) :
... <div id="page" class="hfeed site cf"> <?php tdm_before_header(); ?> <header id="masthead" class="site-header" role="banner"> ...I tried putting the hook code outside and correctly it worked.
I don’t know what to do about the loop though, it still gives me this error:Parse error: syntax error, unexpected T_ENDWHILE in /Users/lucasdechow/Sites/the-damn-margin-blog/wp-content/themes/tdm/functions.php on line 188Hmm perhaps I use the endwhile wrongly…
It says no errors.
But however, there must be something wrong with the hook.
Nope not really.
However i tried just a standard statement and the hook doesn’t work really.
I don’t know might be a core problem?Oh jeez this gets complicated…
This random error appears:
Parse error: syntax error, unexpected T_STRING in /Users/lucasdechow/Sites/the-damn-margin-blog/wp-content/themes/tdm/functions.php on line 229Basically it says add_action doesn’t work… Hmmm
I got no longer the bug from before YAY!
But however it still produces this error:Parse error: syntax error, unexpected T_ENDWHILE in /Users/lucasdechow/Sites/the-damn-margin-blog/wp-content/themes/tdm/functions.php on line 227I tried removing and moving the endwhile statement but it just doesn’t budge.
Any ideas on how to proceed?
@andrew
Thanks again for looking into this.Should I leave the curly braces on?
If I dont it gives me this error:
Parse error: syntax error, unexpected T_STRING in /Users/lucasdechow/Sites/the-damn-margin-blog/wp-content/themes/tdm/functions.php on line 186Else it gives me the exact same error as before…
Here you go: http://pastebin.com/47X7zB45
The excerpt closes all the curly brace’s.
This even easy to be checked in Sublime Text 2.I think I might have gone wrong somewhere in the syntax of the loop?