0

I am new with word press stuck in a problem. I have used EXEC-PHP plugin to write php in my text editor and through that I have fetched records from my database. Now I want to share those posts which I have fetched from database on different social sites. For that I have used social 9 plugin. Now I have used the short code in my loop to display the social icons with every post, but when I share the post and open it from any social site it directs me to my word press site but shows no content on it. Here is the code I have been using to fetch data and to share the posts.

<?php
    global $wpdb;

        $items_per_page = 10;
        $id_post = isset( $_GET['id'] ) ? abs( (int) $_GET['id'] ) : 1;
        $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
        $chapter = isset( $_GET['chapter_no'] ) ? abs( (int) $_GET['chapter_no'] ) : 1;
        $bookName= isset( $_GET['book'] ) ? urldecode ( $_GET['book'] ) : 1;
        $offset = ( $page * $items_per_page ) - $items_per_page;

        $query = "(Select id, hadith_no, content FROM data WHERE book='$bookName' AND chapter_no='$chapter')";

        $total_query = "SELECT COUNT(*) FROM (${query}) AS combined_table";
        $total = $wpdb->get_var( $total_query );

        $latestposts = $wpdb->get_results("Select id, hadith_no, content FROM data WHERE book='$bookName' AND chapter_no='$chapter' LIMIT $items_per_page OFFSET $offset");

        foreach ($latestposts as $latestpost) {
        echo $latestpost->hadith_no." ".str_repeat('&nbsp;', 140)." <a href='http://localhost:8082/tps/permalinks/?id=$latestpost->id'>Permalink</a>  ".$latestpost->content."<br>";
    $text = $latestpost->content;
    $words = extractCommonWords($text);
    echo  "Tags: <a>" .implode(' , ', array_keys($words)).  "</a>"; 
    echo do_shortcode('[Social9_Share]');
        }
    ?>

Please anyone help me with this, thank you.

4

0 回答 0