Clarification… I am first trying to do this and edit the static pages I made with the default template…
Default page template for page file for any theme is page.php
Thank you.
So I pulled the page.php fle. Here are it’s contents:
<?php
/**
* The template for displaying all pages.
*
* @package Sela
*/
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'hero' ); ?>
<?php endwhile; ?>
<?php rewind_posts(); ?>
<div class="content-wrapper <?php echo sela_additional_class(); ?>">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) {
comments_template();
}
?>
<?php endwhile; // end of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
</div><!-- .content-wrapper -->
<?php get_footer(); ?>
If I want to add sharing icons beneath the title and above the body of the page, how would I do that? / Where would I add those? Am I in the wrong file?
I placed the code as you can see here in page.php:
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( function_exists( 'sharing_display' ) ) {
sharing_display( '', true );
}
if ( class_exists( 'Jetpack_Likes' ) ) {
$custom_likes = new Jetpack_Likes;
echo $custom_likes->post_likes( '' );
}
?>
<?php get_template_part( 'content', 'page' ); ?>
This places the social sharing just above the post title (as expected).
Any idea how to change the actual post? To move them below the post title?
Follow up question on this… it seems that all the social sharing throughout the site is disabled now unless I manually add them with the above code? The social sharing option appears when editing posts and i check the box… however, checking it does nothing on the blog post page. so now i have to go to each template and add them back by hand?
Another example is the page.php template above… when I added the icons above the title it removed them from below the post. So I had to put the code in both places to get them above and below.
So two questions now, 1. how can I get the social sharing below page / post titles?… and 2. Is there a way to modify the above code so it is not removing all the wordpress added social sharing areas?
Here is what I added to my functions.php if you need to see that:
/**
* Adds functions for manually placing social sharing and likes
*
*/
function jptweak_remove_share() {
remove_filter( 'the_content', 'sharing_display',19 );
remove_filter( 'the_excerpt', 'sharing_display',19 );
if ( class_exists( 'Jetpack_Likes' ) ) {
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
}
}
add_action( 'loop_start', 'jptweak_remove_share' );
?>
Okay so I answered the second question myself… i simply remove the function jptweak_remove_share portion of the functions.php and left the add_action part and that fixed the problem with the social sharing areas being removed. so now I am just adding them in addition to where wordpress adds them based on the checkboxes.
But question 1 still remained… how can i move them to below titles in pages/posts? are there other php files I should be looking into editing?
figured it out.
content.php and content-page.php were where i needed to add these areas below the titles.