-
AuthorPosts
-
January 1, 2014 at 2:33 pm #204256
In it’s most simple form, I take a copy of single.php – rename it to single-report.php – and it get’s picked up – there appear to be two issues though – both of which must be easily solvable
1 – the opening article tag …
<article class="post-355 report type-report status-draft hentry category-workshops tag-owls tag-wales post-entry post-entry-type-standard post-entry-355 post-loop-1 post-parity-odd post-entry-last multi-big " itemscope="itemscope" itemtype="http://schema.org/CreativeWork">
has report in the second element of the class … which means that it renders with all the text slammed right to the left hand side – whereas posts have it nicely indented so that the gravatar is effectively in a nice column of it’s own, along with the dotted line. Via Safari Inspector, I know that if I change the article rage where is states the class is ‘report’ to ‘post’ it all snaps into place correctly – as per below
<article class="post-355 post type-report status-draft hentry category-workshops tag-owls tag-wales post-entry post-entry-type-standard post-entry-355 post-loop-1 post-parity-odd post-entry-last multi-big " itemscope="itemscope" itemtype="http://schema.org/CreativeWork">
So what do I need to add to my CSS to have ‘report’ act in the same indented fashion as ‘post’?
2 – All my single-whatever.php templates read Blog at the top left – how can I have this pick up the post type that is in use, so reports read report – client-gallery reads Client Gallery, etc
Many thanks in advance – I have an image here of the issues noted above so you can visually see what my issues are
http://natureslens.co.uk/wp-content/uploads/2014/01/wrong.png
January 1, 2014 at 3:44 pm #204261Hi DavidMiles!
1) Make a copy of /wp-content/themes/enfold/includes/loop-index.php and add it to the child theme folder (/wp-content/themes/enfold-child/includes/loop-index.php). Then open up the file and replace
echo "<article class='".implode(" ", get_post_class('post-entry post-entry-type-'.$post_format . " " . $post_class . " ".$with_slider))."' ".avia_markup_helper(array('context' => 'entry','echo'=>false)).">";
with
echo "<article class='".implode(" ", get_post_class('post-entry post post-entry-type-'.$post_format . " " . $post_class . " ".$with_slider))."' ".avia_markup_helper(array('context' => 'entry','echo'=>false)).">";
2) Open up your single-report.php and search for
$title = __('Blog - Latest News', 'avia_framework'); //default blog title
Replace “Blog – Latest News” with your custom text (i.e. post type name).
Best regards,
PeterJanuary 1, 2014 at 3:58 pm #204264Awesome – will try it now – thanks for the swift reply
January 1, 2014 at 4:39 pm #204270Almost there – the indenting is correct, the top left link still reads ‘blog’ – I made the change you suggested – it is the area on the same line as the breadcrumb trail, but on the left
- This reply was modified 10 years, 10 months ago by DavidMiles.
January 2, 2014 at 3:34 am #204363Hi!
Did you change the title on single-report.php file?
$title = __('Blog - Latest News', 'avia_framework'); //default blog title
Replace it with:
$title = __('Reports, 'avia_framework'); //default blog title
Cheers!
IsmaelJanuary 2, 2014 at 12:29 pm #204463Yup – and uploaded it
January 2, 2014 at 6:54 pm #204592Hi!
Do you have a page named just “Blog”? If you change the name of that page does it change as well?
Regards,
DevinJanuary 2, 2014 at 6:58 pm #204597January 3, 2014 at 8:51 am #204917Hey!
Please try to add this on the child theme’s functions.php:
add_filter('avf_title_args', 'alter_single_post_title', 10, 2); function alter_single_post_title($args,$id) { if (is_single()) { $args['title'] = ucfirst(get_post_type($id)); $args['link'] = get_permalink($id); } return $args; }
Best regards,
IsmaelJanuary 3, 2014 at 12:54 pm #204975Cheers Ishmael – that worked – the reports now read report – the other change is that Blog posts now read post – which is fine for me – does get_post_type return the friendly name of the CPT – or will I have to parse out the underscores in double barrelled ones, such as client_galleries
January 4, 2014 at 6:51 am #205254Hey!
If I am not mistaken it will return the name of the CPT. Please test it further. :)
Best regards,
IsmaelJanuary 4, 2014 at 12:58 pm #205310Although my Client Gallery is named that – the CPT Name of client-gallery was being returned – which was not ideal – so I added to your function and now it becomes
add_filter('avf_title_args', 'alter_single_post_title', 10, 2); function alter_single_post_title($args,$id) { if (is_single()) { $type_title = get_post_type($id); $type_title = str_replace("-", " ", $type_title); $type_title = str_replace("_", " ", $type_title); $type_title = ucwords($type_title); $args['title'] = $type_title; $args['link'] = get_permalink($id); }
Meaning now in the top left it does read Client Gallery
-
AuthorPosts
- The topic ‘Adding new templates for custom post type additions’ is closed to new replies.