How to add custom HTML at the end of Post titles in Genesis

Community Forums Forums Design Tips and Tricks How to add custom HTML at the end of Post titles in Genesis

This topic is: not resolved

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  ibadullah 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #103117

    ibadullah
    Member
    Post count: 6

    Hello,

    I am moving my site to genesis framework and I am really new here.

    I want to customize my theme but without your help I wouldn’t able to do anything so please help me (:

    Currently I’m running a image gallery website and I want to transfer this feature to genesis framework.

    I want to display the number of images in a post on the title like this screenshot: http://prntscr.com/3eyfbb

    Below is the code which I have to replace with the current the_title(); but I’m failed to find in the whole files :(

    the_title(); global $numpages; global $page ; echo ' ('.$numpages.' Images)';

    How can I replace this with the current Post title?

    #103122

    braddalton
    Participant
    Post count: 9916

    Use one of the title filters to append it to the end of each title.

    genesis_post_title_text
    Default value: get_the_title()
    Applied to the title in the genesis_do_post_title function.

    genesis_post_title_output
    Default value: $title
    Applied to the output of the title and wrapping heading tags in the genesis_do_post_title function.


    #103124

    ibadullah
    Member
    Post count: 6

    Can you please guide me how to do it?

    I’m really confused.

    I find this get_the_title() code in lib/structure/post.php

    $title = apply_filters( 'genesis_post_title_text', get_the_title() );
    `
    I tried to replace with this
    $title = apply_filters( 'genesis_post_title_text', the_title(); global $numpages; global $page ; echo ' ('.$numpages.' Images)'; );

    But it giving me an error!

    #103136

    braddalton
    Participant
    Post count: 9916

    Never edit any code in Genesis.

    Always use the filter in a child themes functions file.

    Using filter functions in WordPress


    #103172

    ibadullah
    Member
    Post count: 6

    I am glad that you’re helping me a lot!

    I understand I have to make changes in functions.php and I’ve to create my custom functions using hooks and filters.

    But as I said earlier I’m using framework first time I’m still unable to create my own first function so please help me how should I code this? ):

    function my_function_name() {
      // Your custom code goes here, between the curly braces
     $title = the_title(); global $numpages; global $page ; echo ' ('.$numpages.' Images)'; );
    }
    add_filter('genesis_post_title_text','my_function_name');
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.