Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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

    http://natureslens.co.uk/wp-content/uploads/2014/01/alignment-correct-by-changing-report-to-post-within-the-class-tag.png

    #204261

    Hi 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,
    Peter

    #204264

    Awesome – will try it now – thanks for the swift reply

    #204270

    Almost 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, 11 months ago by DavidMiles.
    #204363

    Hi!

    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!
    Ismael

    #204463

    Yup – and uploaded it

    template

    #204592

    Hi!

    Do you have a page named just “Blog”? If you change the name of that page does it change as well?

    Regards,
    Devin

    #204597

    Yes

    #204917

    Hey!

    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,
    Ismael

    #204975

    Cheers 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

    #205254

    Hey!

    If I am not mistaken it will return the name of the CPT. Please test it further. :)

    Best regards,
    Ismael

    #205310

    Although 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

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Adding new templates for custom post type additions’ is closed to new replies.