• Phillip

    (@phillustration)


    Hi there,

    I am just trying to display a …read more on the home page (static page) of my website.

    But the following code seems to ignore the read more in the page that I have created.

    <?php
    		$page = get_page_by_title( 'ABOUT US' );
    		$content = apply_filters('the_content', $page->post_content);
    		echo $content();
    ?>

    Thanks for any help,

    Phil

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hi @-Phillip

    You can try this once

    <?php
    		$page = get_page_by_title( 'ABOUT US' );
    		$content = apply_filters('the_content', $page->post_excerpt);
    		echo $content();
    ?>

    If problem not solved you can report.

    Thank You!!

    Thread Starter Phillip

    (@phillustration)

    Hi sanjog,

    Thanks for the help, i still couldn’t get it to work. Does this only apply to posts with excerpts? I should have said that i am trying to pull content in from a page and i don’t think they have an excerpt option?

    Thanks again,

    Phil

    Hi -@Phillip

    Please can you give me your site URL.So that i can know where do you want read more link.

    Thank You!!

    Hi-@Phillip

    The excerpts automatically displays read more link after certain word.
    That certain word is 55 by default in WordPress.However you can change that.

    Thank You!

    Thread Starter Phillip

    (@phillustration)

    Hi Sanjog,

    Thanks for your time and effort!

    Here is the url…

    https://careyindustrial.com.au/

    That first column ‘ABOUT US’ should be finishing after one paragraph where it says “Quick Parts”

    Thanks again,

    Phil

    Hi -@Phillip

    Can you please tell me how are you displaying content in front page???
    I see there three column.How these data are retrived from each page??

    Thank You!!

    Thread Starter Phillip

    (@phillustration)

    Yep sure, the content in the first ABOUT US column is pulled through using…

    <?php
    $page = get_page_by_title( 'ABOUT US' );
    $content = apply_filters('the_content', $page->post_content);
    echo $content();
    ?>

    Home page is set as my static page.

    Thanks again!,

    Phil

    Hi-@Phillip

    Now you need to add manually your read more link.
    1.Add this line to your functions.php file.

    add_action( 'init', 'my_add_excerpts_to_pages' );
    function my_add_excerpts_to_pages() {
        add_post_type_support( 'page', 'excerpt' );
    }

    2.This will add excerpt field in your page edit section.
    3.Then in that excerpt field copy and paste your content till from where you want Read More.. link.
    4.Use the below code:

    <?php
    		$page = get_page_by_title( 'ABOUT US' );
    		$content = apply_filters('the_content', $page->post_excerpt);
    		echo $content();?>
    <a href="<?php the_permalink();?>">Read More...</a>
    <?php
    ?>

    Report any problem.

    Thank You!!

    Thread Starter Phillip

    (@phillustration)

    hmm, well the excerpt field shows up!

    but then the rest just goes blank?

    https://careyindustrial.com.au/

    Hi -@Phillip

    I don’t know why are you having problem.Cause it worked fine for me.
    Did you added the content in about us page’s excerpt field???.
    Don’t forget to update by adding content to excerpt field.
    Once can you please add
    printr($page);
    just below$page = get_page_by_title( 'ABOUT US' ); line and show the browser result.

    Thank You!!

    Thread Starter Phillip

    (@phillustration)

    Ok, I have changed it to…

    <?php
    	$page = get_page_by_title( 'ABOUT US' );
    	printr($page);
    	$content = apply_filters('the_content', $page->post_excerpt);
    	echo $content();?>
    <a>">Read More...</a>
    <?php
    ?>

    It doesn’t seem to do anything in the browser. ??

    Hi -@Phillip

    It seems that the data is not retrieved from this particular file you are editing.It is pulling data from different file.
    I would like you to figure out from which file the content are actually showing???

    Thank You!!

    Thread Starter Phillip

    (@phillustration)

    Hi Sanjog!

    I think it i working now!

    I removed the () after $content and it worked!

    <?php
    	$page = get_page_by_title( 'ABOUT US' );
    	$content = apply_filters('the_content', $page->post_excerpt);
    	echo $content;
    ?>
    	<a href="<?php the_permalink();?>">Read More...</a>
    <?php
    ?>

    Any idea why for future reference?

    Thanks so much for your help! ??

    Phil

    Hi -@Phillip

    Very Sorry I didn’t see this () either.
    $content is a variable that is storing your post excerpt not a function.
    Cause function need to have ().
    And while display variable you will just echo $content not echo $content();
    Oh Very Happy to hear that your problem is solved.
    Please don’t forget to add this thread as resolved.

    Thank You!!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Read more’ is closed to new replies.