Get exclusive CAP network offers from top brands

View CAP Offers

WordPress Php Help

[bsa_pro_ad_space id=2]
  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #628990
    CasinoSasa
    Member

    Is anyone familiar with PHP And wordpress enough to help a man out.. Im trying to use wordpress for a news section only.. Having my site on .php pages.. I wish to use the wordpress news items on my homepage of my .php site.. I have googled and searched wordpress and they do have a page dedicated to this. But it only shows how to display the titles and none of the text..

    Does anyone know how to change the php code in order to render out a line or 2 of text as well as the title.

    This is the code from wordpress in order to integrate the posts in to a standard php website..
    [PHP]
    < ?php query_posts('showposts=3'); ?>
    < ?php while (have_posts()) : the_post(); ?>
    < a href="” rel=”bookmark” title=”Permanent Link to “>

    < ?php endwhile;?>
    [/PHP]

    Does anybody know how to modify this so it shows a line or 2 of the content as well rather than just the title to the post.. ?

    regards
    gaz

    #829661
    Anonymous
    Inactive

    Hey so let me get this correct.

    You have wordpress installed, and you have news items on it.

    But you also have a .php pages outside of the wordpress install, and you would like to pull those wordpress news items out and display them on your .php pages?

    Rak

    #829662
    Anonymous
    Inactive

    [PHP]include(‘path-to-wp/wp-load.php’);
    $recent_posts = wp_get_recent_posts(array(‘numberposts’ => 10));
    echo ‘

      ‘;
      foreach($recent_posts as $post) {
      echo ‘

    • ‘, $post, ‘
    • ‘;
      }
      echo ‘

    ‘;[/PHP]

    once wp-load.php is loaded you have access to all of WPs functions.

    #829665
    CasinoSasa
    Member

    @Rak 246758 wrote:

    once wp-load.php is loaded you have access to all of WPs functions.

    Hi rak, that maybe true but I have no idea what WP functions are or what you can do with them :)

    But you are correct in I want to basically pull wordpress posts into my .php pages.. That code above just renders out the same as I already have. It just shows the titles of the posts.. I want to show some of the text too.. Like as teaser text. How do i show some text aswell as the title link?

    #829668
    Poker Zealot
    Member

    @societyofslots 246750 wrote:

    Is anyone familiar with PHP And wordpress enough to help a man out.. Im trying to use wordpress for a news section only.. Having my site on .php pages.. I wish to use the wordpress news items on my homepage of my .php site.. I have googled and searched wordpress and they do have a page dedicated to this. But it only shows how to display the titles and none of the text..

    Does anyone know how to change the php code in order to render out a line or 2 of text as well as the title.

    This is the code from wordpress in order to integrate the posts in to a standard php website..
    [PHP]
    < ?php query_posts('showposts=3'); ?>
    < ?php while (have_posts()) : the_post(); ?>
    < a href="” rel=”bookmark” title=”Permanent Link to “>

    < ?php endwhile;?>
    [/PHP]

    Does anybody know how to modify this so it shows a line or 2 of the content as well rather than just the title to the post.. ?

    regards
    gaz

    In my eyes you should avoid the overload and getting the posts directly out of the database.
    There is absolutely no point in loading the complete wordpress core plus a small theme to display three news posts within another site.

    #829671
    CasinoSasa
    Member

    Sounds good smartface.. But how do I do that ?

    #829672
    Anonymous
    Inactive

    I dont use wordpress but you have the post, you just need the value

    Code:
    < ?php query_posts('showposts=3'); ?>
    < ?php while (have_posts()) : the_post(); ?>
    < a href="” rel=”bookmark” title=”Permanent Link to “>
    // Not sure what they call the article con but this will 200 characters you can make it a full word with a little more code
    < ?php endwhile;?>
    #829680
    CasinoSasa
    Member

    Well were getting closer.. It does render out the wordpress content.. But it renders it all out.. There is no character limit – it just chucks out the whole post for each one.. :)

    #829686
    Anonymous
    Inactive

    @societyofslots 246782 wrote:

    Well were getting closer.. It does render out the wordpress content.. But it renders it all out.. There is no character limit – it just chucks out the whole post for each one.. :)

    hmm

    try this

    where 20 should be the # of characters

    #829688
    Poker Zealot
    Member

    you’d rather use the function the_excerpt() instead of the_content()

    #829694
    CasinoSasa
    Member

    Houston we have landed!

    Id like to thank you both for your help.. All Free chips for the code and smartface for his “mod” as it worked with the_excerpt() rather than the_content()..

    So thanks peeps.. much appreciated :)

Viewing 11 posts - 1 through 11 (of 11 total)