- This topic has 9 replies, 3 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 6, 2019 at 1:23 pm #830969
Marco
Hello
1. How do I replace the page title with e.g. the name of the parent page – couldn’t find a filter to replace the page-title?
2. Where do I set which picture size to show on the attachment page – for some reason it is a 720-300px image which is not wide enough.
3. How do I remove the comment form on the attachment page only?Thank you in advance for your input.
March 6, 2019 at 4:54 pm #831122Tom
Lead DeveloperLead DeveloperHi there,
1. I’m not sure if there’s a filter for the page title, unfortunately. You would likely need to create an
attachment.php
template file in your child theme. Then you can replacethe_title()
with the necessary function to grab the parent page title.2. Something like this might do it: https://gist.github.com/rfmeier/5753101
3. This plugin should do it: https://wordpress.org/plugins/disable-comments/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 6, 2019 at 5:51 pm #831169Marco
Thanks for your input
1. as to creating an attachment.php template file, I guess I can just copy the single.php file from the GP theme? – to bad there is no filter to manipulate the page title – was wondering whether you would consider adding a filter in one of your next versions.
the custom template file only seems to work if the file is in the main child theme folder – is there a way to put those templates into a sub-folder?2. that code worked
3. found the following filter that seems to work:
/* Comment Form: Remove comment form from attachment page ---------------------------------------------------------------------------- */ function themeprefix_remove_attachment_comments( $open, $post_id ) { //return false; $post = get_post( $post_id ); if ( $post->post_type == 'attachment' ) $open = false; return $open; } add_filter( 'comments_open', 'themeprefix_remove_attachment_comments', 10, 2 );
March 7, 2019 at 6:58 am #831806Tom
Lead DeveloperLead Developer1.
the_title()
is filterable by default, but it applies to a bunch of elements throughout WordPress (menu items, widget titles etc..).Yes, I would copy
single.php
, and you’ll likely need to mergecontent-single.php
in place of theget_template_part()
function in there, as I think that file containsthe_title()
.3. Nice! Thanks for sharing 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 15, 2019 at 3:38 am #839547Matthew
hi Tom,
I’ve just set up the theme and this is my first post. I really like the clean, basic and neutral front end which will allow my artwork to stand out.
I also want to create an
attachment.php
template file dedicated for images and will copy
single.php
for this purpose.When you say “you’ll likely need to merge
content-single.php
in place of theget_template_part()
function..” does this mean I add all the code that’s contained incontent-single.php
directly intosingle.php
deleting and replacing the current code of:get_template_part( 'content', 'single' );
thanks!
March 15, 2019 at 9:56 am #840045Tom
Lead DeveloperLead DeveloperExactly 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 15, 2019 at 10:39 pm #840366Matthew
hi Tom,
Unfortunately this didn’t work and resulted in the white screen.
In place of
get_template_part( 'content', 'single' );
I tried the following:1) The entire code from
content-single
2) All code fromcontent-single
within<article>
tag, including this tag
3) All code fromcontent-single
within<div class="inside-article">
tag, including this tag
4) All code fromcontent-single
within<div class="inside-article">
tag, excluding this tag.Tried this with a file named
attachment.php
in both Child theme and Parent folderCould you possibly set up an attachment page at your end to send across? At the moment I’m guessing a bit here.
Thanks,
March 16, 2019 at 8:50 am #840790Tom
Lead DeveloperLead DeveloperGive this a shot: https://gist.github.com/generatepress/4e033b8e30efce6cffc07fe34cb2ac58
Let me know 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 17, 2019 at 8:33 pm #841792Matthew
Thanks that did the trick!
But it is only missing the image so I went into the WP TwentyNineteen theme file for attachments and copied below code and placed it into
<div class="entry-content">
of my newattachments.php
file:<figure> <?php /** * Filter the default twentynineteen image attachment size. * * @since Twenty Sixteen 1.0 * * @param string $image_size Image size. Default 'large'. */ $image_size = apply_filters( 'twentynineteen_attachment_size', 'medium' ); echo wp_get_attachment_image( get_the_ID(), $image_size ); ?> </figure>
This works and I can even change the image size but I am concerned it is not GeneratePress code. How can it apply this filter correctly. Should I change anything here or leave it?
thanks
March 18, 2019 at 8:43 am #842320Tom
Lead DeveloperLead DeveloperYou can just leave it, as you can change the size directly without the need for a filter.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.