but they that this is a WordPress issue, because WordPress decides the order of these elements.
Yes and no. There is sort of a way to set an order. Depending on how the theme and plugin are set up can change the order.
A quick example of this would be the add_action
hook. Let’s say your theme wanted to add some arbitrary CSS. You could hook to wp_head
. Let’s say another plugin then hooks to that. It could potentially print another stylesheet before the theme does by using the $priority
argument.
quick code:
// from plugin
add_action( 'wp_head', 'super_simple_CSS', 0 );
function super_simple_CSS(){
// some neat code here
}
// from the theme
add_action( 'wp_head', array( 'Theme_class', 'custom_css' ), 20 );
class Theme_Class {
public function custom_css(){
// super duper neat theme css
}
}
When the the wp_head
fires it will print out the super_simple_CSS
first and then the custom_css
. If you wanted to change that you could do something like:
remove_action( 'wp_head', 'super_simple_CSS' );
remove_action( 'wp_head', array( 'Theme_class', 'custom_css' ), 20 );
add_action( 'wp_head', array( 'Theme_Class', 'custom_css' ), 0 );
add_action( 'wp_head', super_simple_CSS', 20 );
While it can be a WordPress related issue it also can fall on the theme or plugin on when that action/filter does fire. 🙂
Hope that helps a bit. 🙂
Thread Starter
Lutz.H
(@lutzh-1)
Hi Hose,
thanks for your reply!
It helped understanding, how plugins work … I didn’t know that because and don’t have a clue of PHP and what’s going on behind the scenes of WordPress ;))
On the other hand, I’m using PageLines as theme and Shareaholic plugin for the Sharing-Buttons and can only pray that I will find somewhere in the code of both snippets like your example, adding somewhere the in-post pagination (theme) and the sharing buttons (plugin) so that I know the function’s exact name to remove_action and add_action anew. Especially on the theme that can take a while – as I can’t do a global search on my server including the content of all files …
So if someone can grant mor help on that, I’d be glad!
If you are referring to https://wordpress.org/plugins/shareaholic/
Taking a quick look it appears to be in:
https://plugins.trac.wordpress.org/browser/shareaholic/tags/7.6.1.8/shareaholic.php#L103
It appears to hook to the_content
via:
add_action('the_content', array('ShareaholicPublic', 'draw_canvases') );
If you are using a functionality plugin or a child theme you can add:
remove_action('the_content', array('ShareaholicPublic', 'draw_canvases') );
add_action('the_content', array('ShareaholicPublic', 'draw_canvases'), 100 );
To see if that helps. Unfortunately I’m not too familiar with how PageLines does things so I can’t be of much help there but I do hope that does help steer you in the right direction. 🙂
Thread Starter
Lutz.H
(@lutzh-1)
Dear Jose,
thanks again.
Well, this code kind of works … but not in the way I wanted it ;))
Instead of
post content
Sharaholic links
post-by-post navigation
in-post navigation
I now have
post content
post-by-post navigation
Sharaholic links
in-post navigation
In other words: the in-post navigation is still last and should be #2 after the post content …
Any idea what else I could try?
I think I know now. I want to say it could be in the way the theme uses two functions that behave rather oddly. The two are the_content
and wp_link_pages
.
I’m guessing the theme has something like:
// somewhere in the theme
the_content();
wp_link_pages;
So, what happens is anything that is hooked to the_content
will fire in-between those two functions. wp_link_pages
is what <!--nextpage-->
is generally for.
So, to a degree the theme is what is controlling that. There is a way of changing that but would require modifying some of the theme’s files, which can lead to trouble if it does get updated. Creating a child theme would be the best route but that means creating files and perhaps using an FTP program.
In order to do so you would create a file where
the_content();
wp_link_pages();
is used and remove wp_link_pages()
. From there in the functions.php
file you would add:
add_action( 'the_content', 'add_in_post_pagination', 5 );
function add_in_post_pagination( $content ){
return $content . wp_link_pages( array( 'echo' => 0 ) );
}
That is one way I can think of but, as I said, I’m not too familiar with the theme’s codebase.
Side-note. The above method is taking into account a child theme is being used.
Thread Starter
Lutz.H
(@lutzh-1)
Hi Jose,
thanks again!
The only part of the theme code where I found the wp_link_pages function is in the file class.posts.php. I knew because I changed that befor to wp_link_pages_titled in order to show the <!–pagetitle:–> instead of just numbers.
Works great: http://mobiwatch.net/review-honor-6-plus-5-5-giant-with-mega-battery/3/
I guess the problem is, that Shareaholic adds its code to the_content as you found in the code of Shareholic. And with that, it resides before the link_pages!
Do you see any solution for that?
I copied the theme’s class.post.php for you here: http://www.dropbox.com/sh/go3nxwdlxhpvnwv/AABagX-4bM7LE5gEDTfI3q-wa?dl=0
Thread Starter
Lutz.H
(@lutzh-1)