WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help me adding post title inside this code (5 posts)

  1. locovip
    Member
    Posted 1 year ago #

    I want to add the single post title function to this code:

    function wpcol_one_third ($atts, $content = null) {
    
    			return '<div' . $this->wpcol_div_atts($atts,'wpcol-one-third') . '>'.$this->wpcol_strip_autop($content).'</div>';
    
    		}
    
    		function wpcol_one_third_end($atts, $content = null) {
    
    		  return '<div' . $this->wpcol_div_atts($atts,'wpcol-one-third wpcol-last') . '>'.$this->wpcol_strip_autop($content).'</div>'.$this->wpcol_add_divider();
    
    		}

    It consists of a plugin that works with columns. I need that it gets the default single post title code to show it inside the provided code.
    Is that possible? Help me please!

    Regards

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    the post title would possibly be accessible by:

    global $post; $posttitle = apply_filters('the_title',$post->post_title);

    but where exactly do you want the title to show in the final column layout?

  3. locovip
    Member
    Posted 1 year ago #

    Thank you alchymyth for the quick reply!
    Yes I wanted to show the post title on top of the one_third column.
    For now I have writted (the title post) manually as you can see in
    http://maggyvillarroel.com/adsos/

    but my initial idea was to implement the php changes to implement the post title so I will try your solution even I don't know exactly where should add your provided code.

    Thank you very much again,alchymyth.

    Kind regards

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    as you are adding the title to the last third column, you could try to add it here:

    function wpcol_one_third_end($atts, $content = null) {
    
    		  return '<div' . $this->wpcol_div_atts($atts,'wpcol-one-third wpcol-last') . '>'.$this->wpcol_strip_autop($content).'</div>'.$this->wpcol_add_divider();
    
    		}

    like so (untested):

    function wpcol_one_third_end($atts, $content = null) {
    global $post;
    		  return '<div' . $this->wpcol_div_atts($atts,'wpcol-one-third wpcol-last') .'><h1><strong>'.apply_filters('the_title',$post->post_title).'</strong></h1>'.$this->wpcol_strip_autop($content).'</div>'.$this->wpcol_add_divider();
    
    		}

    details might depend on the general coding of the theme.
    what theme are you using?

  5. locovip
    Member
    Posted 1 year ago #

    It worked like a charm!
    The only thing is that the post title repeats in every one_third column...although the "hack" worked, I think would be better to add the Title manually, just takes a little bit of time and doesn't repeat in every one_third column.
    I will take into consideration the code you provided here for "maybe" implement it in the future if the site needs, it's very useful.

    Thank a lot once again and kind regards.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags