please how do i display my blog posts on mybb portal
#1
please i have a main site www.relationshipvilla.com , i want to display the blog latest posts on mybb portal www.relationshipvilla.com/forum.  just like displaying only the mainsite post titles . 

forum : www.relationshipvilla.com/forum
Reply
#2
(2017-08-26, 05:16 PM)Papergoddess Wrote: please i have a main site www.relationshipvilla.com , i want to display the blog latest posts on mybb portal www.relationshipvilla.com/forum.  just like displaying only the mainsite post titles . 

forum : www.relationshipvilla.com/forum

That can be kinda hard.

did you use one database for both wordpress and mybb or do they both have their own? (did you use softaculous or did you do a install yourself).

Is it on the same server?

I can probably do the script for you, i need details tho.

Also, is it global or is it only on index, portal or such.

$mysqli = new mysqli('localhost', 'root', 'password', 'dbname');
/*
 * This is the "official" OO way to do it,
 * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
 */
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}
$query3 = $mysqli->query("SELECT * FROM `wp_posts` WHERE `post_type` = 'post' LIMIT 0,5");




if ($query3->num_rows > 0) {

    while ($result = $db->fetch_array($query3)) {

        $data1 = $result['post_title'];
        $data0 = $result['id'];
		$date = $result['post_date'];
        
        echo "<div class='row bootstrap snippets'>
        <div class='col-md-9 col-sm-7'>
        <h2><a href='/personal/".$result[post_name]."'>$data1</a> <small>$date</small> $data0</h2>
        </div> ";
        echo "</div>";
       

    }
}
else {
    echo "<h2>Sorry Nothing Found</h2>";
}

just change it to what you wish for it to be designed as.

Change root to your db username, password to your password and dbname to your database name.

[Image: screen.png]

this is what I came up with. But, this is for index file.

if you need this in global i could do it for you. But you be best to add this to the index.php file. If you wish, i could do that. But I would need your index file.
Reply
#3
EVERYTHING IS DIFFERENT. PLEASE CAN YOU GIVE ME STEP BY STEP DETAILS ON HOW TO DO IT? THANK YOU
Reply
#4
(2017-09-01, 09:25 AM)Papergoddess Wrote: EVERYTHING IS DIFFERENT. PLEASE CAN YOU GIVE ME STEP BY STEP DETAILS ON HOW TO DO IT? THANK YOU

Fill out the connection details
$mysqli = new mysqli('localhost', 'root', 'password', 'dbname');
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}
This is where you change the prefix:

$query3 = $mysqli->query("SELECT * FROM `wp_posts` WHERE `post_type` = 'post' LIMIT 0,5");

Change the details in the loop:

if ($query3->num_rows > 0) {

    while ($result = $db->fetch_array($query3)) {

        $data1 = $result['post_title'];
        $data0 = $result['id'];
        $date = $result['post_date'];
        
        echo "<div class='row bootstrap snippets'>
        <div class='col-md-9 col-sm-7'>
        <h2><a href='/personal/".$result[post_name]."'>$data1</a> <small>$date</small> $data0</h2>
        </div> ";
        echo "</div>";
       

    }
}
else {
    echo "<h2>Sorry Nothing Found</h2>";
} 

if you still need help or such just reply.

The mysqli is the new way of connecting to the database. This will open up another connection to a different database
Reply
#5
i dont know anything in php
Reply
#6
(2017-09-01, 05:36 PM)Papergoddess Wrote: i dont know anything in php

Send me the file you wish to be edited, and I will do the changes for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)