Move Author box up

Posted in: Newspaper
Post count: 48

Hello,

I would like to move the author box that can optionally appear on posts to directly underneath the post content.

As in, a line underneath the last word of the post content.

Please could someone advise!

Post count: 18

Assuming you are using module 1, you would edit your includes/modules/td_module_1.php file.

Find the section of code that looks like this(mine starts at line 49):

            if ($this->show_excerpt === true) { //module 7 uses this
                $buffy .= '<p>' . $this->get_excerpt(td_util::get_option('tds_' . 'mod7_content_excerpt')) . '</p>';
                $buffy .= '<div class="more-link-wrap wpb_button td_read_more clearfix">';
                $buffy .= '<a href="' . $this->href . '">' . __td('Continue', TD_THEME_NAME) . '</a>';
                $buffy .= '</div>';
            } else {
                $buffy .= $this->get_content();
            }

            $buffy .= '<footer class="clearfix">';
                $buffy .= $this->get_post_pagination();
                $buffy .= $this->get_review();
                $buffy .= $this->get_the_tags();
                $buffy .= $this->get_source_and_via();
                $buffy .= $this->get_social_sharing();
                $buffy .= $this->get_next_prev_posts();
                $buffy .= $this->get_author_box();
            $buffy .= '</footer>';

and replace it with this:

            if ($this->show_excerpt === true) { //module 7 uses this
                $buffy .= '<p>' . $this->get_excerpt(td_util::get_option('tds_' . 'mod7_content_excerpt')) . '</p>';
                $buffy .= '<div class="more-link-wrap wpb_button td_read_more clearfix">';
                $buffy .= '<a href="' . $this->href . '">' . __td('Continue', TD_THEME_NAME) . '</a>';
                $buffy .= '</div>';
            } else {
                $buffy .= $this->get_content();
                $buffy .= $this->get_author_box();
            }

            $buffy .= '<footer class="clearfix">';
                $buffy .= $this->get_post_pagination();
                $buffy .= $this->get_review();
                $buffy .= $this->get_the_tags();
                $buffy .= $this->get_source_and_via();
                $buffy .= $this->get_social_sharing();
                $buffy .= $this->get_next_prev_posts();
            $buffy .= '</footer>';
Post count: 48

That’s not worked unfortunately – thought I’m not 100% sure what you mean by ‘module 1’. Are you talking about on the category options within theme panel?

Article display is M2
Custom sidebar position is Defualt

Post count: 18

Ok, I’m sorry I didn’t pick up on the fact that you are trying to do this from the Theme Panel.

There is no way for you to change that in the Theme Panel(or anywhere in the wordpress admin). That is something that requires modification of the theme itself. The theme does not have an option for you to choose where to put the author box.

The instructions that I gave are for modifying the files that exist on your server.

Post count: 48

No, sorry I understand that.

Except, when I edited includes/modules/td_module_1.php, it did not work. So it may be the wrong file I’m editing. How do I know which file to edit?

Thanks

Post count: 18

are you using the child theme?

I’ve got to head out for about an hour. I can help more when I get back.

Post count: 48

Not using a child theme, nope.

That’s fine, thanks for your help so far!

Post count: 48

Just to clarify on what I’m looking for, I’ve made a mockup:

http://www.thisisanfield.com/wp-content/uploads/moveauthorbox.png

That’s based on this post:

http://www.thisisanfield.com/2014/02/can-liverpool-end-seven-year-arsenal-jinx/

Post count: 18

Well, as far as I can tell you are using module 1, which is the default module for single posts.

If that is true then making the edits that I suggested in wp-content/themes/Newspaper/includes/modules/td_module_1.php would do exactly what you want. How are you editing these files?

One way we can check to see what module is being loaded is to echo the variable.

On line 94 of your single.php file change <?php to <?php echo $loop_module_id;

Then, just inside the container div on your post you should see a single digit and that is the module number that is being called.

Post count: 48

Got it.. okay, here’s where we’re at.

Your original method DID work. However, because there is an advert and our social media icons plugin in between the bottom of the post and the author box, it didn’t show any differently. I just moved $buffy .= $this->get_author_box(); above the content, and the box appeared above. So your method did work afterall.

However, I need a way to get that author box above the social media icons plugin and the advert, effecively taking priority as the very first thing after the post content.

Any ideas?! Thank you for your help.

Post count: 18

Ahh, the plot thickens…

Most likely your social plugin is using add_filter() to add their output to the end of the_content();

In that case, I think you would you would need to do something like this in your functions.php

// Filter the_content BEFORE the plugin does, this is by setting the priority argument, which is represented by the X.  Need to make sure that number is higher than the one that the plugin uses to add their filter
add_filter( 'the_content', 'my_td_authorbox', X );
function my_td_authorbox($content){
  // Not sure if $this will work in this context, just have to see.
  $content .= $this->get_author_box();
  return $content;
}
Post count: 48

Yep that’s what I was thinking now. Unfortunately that code doesn’t work, and just made a blank white page.

Post count: 18

Yeah, the_content() doesn’t understand $this->get_author_box().

Does this work?

function my_td_authorbox($content){
  global $post;
  $content .= get_author_box($post->ID);
  return $content;
}
Post count: 48

Nope. It didn’t bring up the white page, but it didn’t put the author box under the content either.

Post count: 18

In that case, perhaps a different approach. Add your own hook and change the plugin to call later

In your td_module_1, you could add a hook. Change $buffy .= $this->get_content();

To this:

                $buffy .= $this->get_content();
                my_after_content_hook($buffy);

Then in your plugin files, you need to find the add_filter( 'the_content', 'the_plugin_function_name', $priority); and change it to add_filter( 'my_after_content_hook', 'the_plugin_function_name', $priority);

  • This reply was modified 12 years by webmaster808.
  • This reply was modified 12 years by webmaster808. Reason: Need to modify $buffy with the filter, not $content
Post count: 18

That probably won’t work though, because the plugin is most likely coded to return $content and not $buffy…

That’s all I got. Good luck!

Post count: 48

Can see what you’re doing there, but unfortunately it didn’t work either. It’s also a lot of playing around with the code, which isn’t good for future theme updates. I might just have to settle for imperfection here!

Post count: 48

Thanks for your help!

Viewing 18 posts - 1 through 18 (of 18 total)
You must be logged in to reply to this topic.