Wordpress blog theme modification - php

I am using Primal wordpress theme for the purpose of a simple blogging website.
I want to make a minor change on the home page. I want to remove the "Date, user and comment" line displayed below the title of the each post. I am not able to remove that from the dashboard. Kindly suggest solution. Suggest steps if it requires plug-in modifications.
I want to remove text highlighted in yellow

go to your \wp-content\themes\primal\template-parts\content-single.php
then find the code and comment it
<!--div class="entry-meta">
<span class="date-structure">
<span class="dd"><i class="fa fa-calendar"></i><?php the_time(get_option('date_format')); ?></span>
</span>
<?php primal_author(); ?>
<?php primal_comments_meta(); ?>
<?php primal_edit() ?>
</div--><!-- .entry-meta -->
then save the file
It will work for you.
Thanks

Related

Undefined function the_field in Visual Studio Code

I'm trying to display the data of a ACF but I'm getting this error in Visual Studio Code:
This is the entire code. I tried reinstalling the plugin, added PHP to the path but nothing seems to be working.
Single.php
<?php get_header();?>
<div class="container">
<div class="row">
<div>
<img src="<?php the_post_thumbnail_url('thumbnail'); ?>" id="single_header">
<div id="single_content">
<?php if (have_posts()):while (have_posts()):the_post(); ?>
<?php
$fn=get_the_author_meta('first_name');
$lname=get_the_author_meta('last_name');
$email=get_the_author_meta('email');
?>
<h1 class="text=cenetr nt-3 mb-5 text-primary"><?php the_title();?></h1>
<small>Publishor:<?php echo $fn; ?></small>
<p><?php the_content();?></p>
<?php
endwhile;
endif;
?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div>
<div id="single_extraInfo">
<p>Company: <?php the_field('flight_company'); ?></p>
<p>Date: <?php the_field('flight_date'); ?></p>
<p>Capacity: <?php the_field('flight_capacity'); ?></p>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
On top of what #DaleNguyen adviced above...
Make sure the directory that contains acf plugin is in your Vs Code. Example, instead of only opening the theme directory in Vs Code in which you are probably working, open the entire wp_content directory in your VS Code. That way, when intelephence run in the back-ground, it will be able to reach the plugins folder and acf functions in the acf plugin folder.
In the intelephense, make sure you add wordpress to the list.
#james-serengia answered with one working solution that the ACF plugin folder should be open in the same workspace as the code you are working on and the warning disappears.
Alternatively if that is inconvenient, you can add you can add the ACF stubs to VSCode. It is a bit of messing around but when it is done, it is done. See this explanation.

"Read more" button bug in Wordpress custom theme

I'm new to php coding and I need to fix a bug in my friend's website. Here is the page with the bug http://www.corectura.ro/category/in-presa/ (it's in Romanian, but it doesn't matter). "Citeste mai multe..." is the "Read more..." link and it doesn't work. It just opens the same page (this one: http://www.corectura.ro/category/in-presa/) in a new tab, instead of opening the link/post in order to read more just as the "read more..." button says. The site is on Wordpress platform and has a custom theme.
I've looked into the editor in all the php files for the section where the "read more" is mentioned. I only found it in archive.php and styles.css.
In the styles sheet the only code i found is this one (regarding to the read more link)
.r_more{ display:block; text-align:right; }
And in the archive.php the code below:
<li>
<div class="post_thumbnail"><?php the_post_thumbnail('thumbnail'); ?></div>
<div class="post_content"><h3><?php the_title(); ?></h3>
<div class="date_post"><?php echo ucfirst(get_the_date('F Y')); ?></div>
<?php the_excerpt();
echo 'Citeşte mai multe...';
?>
</div>
</li>
Is there something wrong with this code? Is the syntax correct? Why does it open the same page in a new tab instead of opening the page with the content that's needed to be shown after clicking "Citeste mai multe..." ("Read more...")?
Please help. Thank you.
You are using echo, so you need to change the_permalink() to get_permalink() (which returns the permalink):
echo 'Citeşte mai multe...';
Try this instead:
<?php the_excerpt(); ?>
Citeşte mai multe...

Footer div closing early on a single web page

I am working on a website, http://www.amp.com.pk/contact/. The footer works perfect on all of the pages except the contact page. I have tried wrapping the footer under another div (primary div) but still the problem is there.
Please guide me. Thanks.
<div class="footer-wrapper">
<div class="copyright">
<p style="margin-top:-45px;color:#91703A;font-size:15px;">Adnan Malik Productions</p>
<p style="margin-top:-30px;color:#91703A;font-size:13px;">
Follow us on Facebook | Twitter|AMP © <?php echo date('Y') ?>. ALL RIGHTS RESERVED</div></p>
<div class="credit">Powered By: Inspurate</div>
<div class="clear"></div>
</div>
#colophon .footer-wrapper
{
margin-left:150px;
}
try this and see if it works or not or try giving dimensions in Percent instead of Pixels !
I am sure it will work

Site template not working in wordpress

Okay, so I'm developing a site in wordpress and I have two file templates "Default Template" and "Shop" in both templates I have;
<?php include('breadcrumbs.php'); ?>
and inside the 'breadcrumbs.php' file I the following;
<div class="breadcrumbs">
<div class="container">
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<?php
if (function_exists('show_full_breadcrumb')) {
show_full_breadcrumb();
}
?>
</ol>
</div>
</div>
</div>
</div>
Now these breadcrumbs display properly if it is in the 'default template' like this;
But on the shop page display like this and I have no idea why as they're both including the same file;
now I'm not sure if this would affect much of it but I am also using WooCommerce.
Hopefully someone can help! thanks in advance!
It's definitely a css issue. Something is overriding the styling on that shop page. Use firebug to diagnose the breadcrumbs. Or provide a link so I can look at it. But Firebug will show you the ul styling right on the breadcrumbs and you can A/B between the default and the shop template. Should be an easy fix with the CSS
Hope this helps.

Editing certain parts of page template in User mode

I have a web page I am working on in WP which needs some customization.
Firstly I have created a page template that will be used over and over again, only changing parts of the content. I am wondering about available options for me when enabling this fact, through the Admin panel in the HTML Editor(if possible)...
Hope my question is clear enough for you all.
Let me add some code to show what I am trying to accomplish.
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
//This is what i want to be able to edit
</div>
<div id="features">
//This is what i want to be able to edit
</div>
</div>
Dino:
There are lots of ways you could do this. The main question I would ask you is, who is going to be adding/editing this content? If you're going to have a community of people adding content, the input needs to be stripped and sanitized (to avoid injecting tags or other harmful content). If its just going to be you, then here's the easiest/fastest solution:
Use custom fields. If you can't see them in the post/page edit screen, go to the little tab on the top right of the post-edit screen that says Screen Options (or something like that) and click "Custom Fields".
Once you can see the Custom Fields edit box, you can add as many fields as you want. These are stored as post meta data. You can use the <?php the_meta(); ?> function in the loop to display all of your custom fields.
You can access a specific field by using get_post_meta(). You pass in the postID and the key of the meta field:
<?php echo get_post_meta(get_the_ID(), 'my_key'); ?>
So, for your example, you would add in the post-edit screen:
about: Some text to go in the about section.
features: Some text to go in the features section.
Then, you would access these on your page like so:
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
<?php echo get_post_meta(get_the_ID(), 'about'); ?>
</div>
<div id="features">
<?php echo get_post_meta(get_the_ID(), 'features'); ?>
</div>
</div>

Categories