Category : blogs

I wanted to add comment to every post I make but I keep on getting errors. Comment Controller: public function store(Request $request) { $comments = new Comment; $comments->body =$request->get(‘comment_body’); $comments->user()->associate($request->user()); $blogs = Comment::find(1); $blogs->comments()->save($comments); return back(); } Comment Model: namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; class Comment extends Model { use HasFactory; protected $guarded =[]; ..

Read more

I’m making a blog in Codeigniter. Now on the blog post view page, I want the previous and next post link. This is my controller of blog details. public function blog_details($slug = NULL){ //data $data[‘blog_info’] = $this->Blog_model->get_posts($slug); if(empty($data[‘blog_info’])){ show_404(); } $data[‘post_name’] = $data[‘blog_info’][‘post_name’];//post name $data[‘categories’] = $this->Blog_model->get_categories(); //meta title, discription, keywords $data[‘meta_title’] = $data[‘blog_info’][‘post_name’]; $data[‘meta_description’] ..

Read more

I have been trying to display wordpress blog post categories in a html/php website. This is my code. <select class="form-control" name="Category"> <option>Select Option</option> <?php include(‘blog/wp-load.php’); $category_list = wp_get_post_categories(); foreach($category_list as $category){ ?> <option><?php echo $category->category_name; ?></option> <?php } ?> </select> Its not working. What is wrong with my code? Is this the right method? Can ..

Read more

Mysql code: $sql = "SELECT * FROM page WHERE id=’$Id’"; $stmt =$ConnectingDB->query($sql); while ($DataRows = $stmt->fetch()) { $Page = $DataRows["pagename"]; } Here pagename may contain ‘wordpress-hosting’, ‘ecommerce-hosting’, ‘linux-hosting’…etc The categories in blog post will be WordPress, Ecommerce, Linux..etc I want to display recent posts from a specific category which has first word from the page ..

Read more

Below is my code to display recent posts from blog in html/php page <div class="row"> <?php include(‘blog/wp-load.php’); $recent_posts = wp_get_recent_posts(array( ‘numberposts’ => 3, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’ )); foreach($recent_posts as $post) { echo ‘<div class="col-lg-4">’; echo ‘<div class="blog-entry">’; echo ‘<a href="’, get_permalink($post[‘ID’]), ‘" style="background-image: url(images/BlogImg.png);"></a>’; echo ‘<div class="text">’; echo ‘<div class="meta">’; echo ‘<div><span ..

Read more