get_post_meta in wordpress custom theme - php

i have a client that gave me his wordpress site for re-coding.
and i saw he have a custom theme.
so i tried to edit his site homepage, using the css stylsheet file and i saw that the file containing some code that i can't understant and i will be happy if someone can help me understand what is it and hoe can i edit / find what is this.
i asaw when i'm printing it, it containg somthing that similar to a css class.
this is it:
<?php echo get_post_meta(6,'home-news-title',true);?>

That line displays on the frontend the content of a meta-key named "home-news-title" for the post which ID is 6.
You can find the corresponding post in the admin backend by just hovering the mouse on the post title in the post list window. The ID is shown in the associated URL after ..post.php?post=XX

Related

Add <?php the_content(); ?> to WooCommerce page template

I use Elementor page builder on my WordPress site. There is a problem with it - by default it doesn't allow editing WooCoomerce Shop/Products pages. The solution they say is to add to page templates code. I, being a beginner with no idea of coding, cannot figure out which file to add this code to and where in that file. I have been researching and trying to fix this myself for two weeks now, in vain. Please help me achieve this.
Here's what Elementor say: "Sorry, the content area was not found in your page. You must call the_content function in the current template, in order for Elementor to work on this page."
Go to Elementor setting and then check products in post types
Go to Products, click Edit on the product you want to edit, input something (ie. a full stop-sign '.') in the WP Editor, click Update. (See attached screenshot.)
Screenshot
There seems to be a misconception that Elementor can be used to "edit" any content.
For Elementor to work on a "Page" i.e. the post type that uses either the page.php or any theme declared page templates it requires the_content(); function to present in the code.
Issue #1: WooCommerce uses the woocommerce_content(); function to return the content of the shop.
Issue #2: The Shop output does not use the "Page" or Custom Page template - the output is equivalent to the index.php or home.php, neither of which are editable via Elementor.
Unless you are willing to write a pretty sophisticated function to collect all those elements' data and filter them into the_content(); function, there is currently no way of editing such content directly.
I know it's not the solution you are looking for but that is the current state of affairs. Having said that, some of us are working on all sorts of solutions and maybe, just maybe - we'll come up with a way to have this option available soon ;)
For shop page you should go to Elementor setting and then check products in post types.
Because shop page products are not the content but posts it's the solution.
So inlcude products in post types and edit with elmentor, if for some reason you can't see 'edit with elementor' under shop page, then just open shop page and add
/?elementor and it would enable elementor
NO need to add this code in any page follow these instruction.
You just need to clear cache and cookies your browser, Some time website take previous data to show the web page and give this error.
or
if you open your website private mode then login and go to the page by Elementor you will never face this problem.

What file should I edit to change the wordpress blog post list

What files should I edit to change the structure and content of the posts echoed in the index.php page ?
The ones with circles around them..
I tried editing content.php because it had the <article> tag in the begining but it's not it.. it's the template of the post after you click on it. and not before.
I just want to edit the post previews "boxes", (To add the author picture.. change the elements positionings.. etc') When editing content.php it edits the post itself (for example, after I click on a post, I still see the post edits I made.
Which file is the right one?
**Using wordpress 4.1 Twentyfifteen theme
just edit these in your wp-admin area. Go to Settings->Reading and choose post page is your blog page.
After that just you had to change these in index.php file where is your php code added for calling blog page.
And if you want to change blog title and their description at that time you had to go in content.php file.
Happy :)
If you want edit this list page layout.
first check your post type and then go on content-***.php.
all content come on that post type Template.
Example:
Your post type is page,then go content-page.php file and change on that.

How to make Wordpress Custom page

i m a newbie to wordpress. I have started theme development and encountered these problems. I think these kind of problem does have a solution, but i m not able to find it out.
I m trying to make a custom page. Uptill now i have made header, footer and main index page.
I see that whenever my theme is activated, I see these default index page, with header and footer assign to it.
I have also made some cutom about us , contact us pages using the Add Pages Functionality of wordpress.
My Problem:
1.Now I m trying to make custom product page where I will have more than 100 images on that pages, and then i can change the images, add the images and description and the link url in future. I have made some html code and put it in the text Tab . I can also see the images on the frontend of the Custom page. But my template breaks. Images goes up and description goes far below.
Also i wanted to add fancybox to all the images which are goin to be replaced or added. But again my template breaks.
So can we make custom.php page and do some coding or anything which you feel is the right way of doing it, Please let me know.
Firstly create product.php page in templates folder using below code on top
<?php
/*
Template Name: My Product Page
*/
get_header();
// write your code here
get_footer();
Then, assign the above template to the page in admin.
Then, that page you can call in menu.
For more detail, check here :- http://codex.wordpress.org/Page_Templates
Actually you don't really need to create a custom template for this unless if you are planing to use that same template on another page.
If your page name is products , just create a file called page-products.php in your theme root. and write your code inside that page.
If your planing to develop themes first be comfirtable with wp template hierarchy.
http://codex.wordpress.org/Template_Hierarchy

WordPress archive-custom.php page not working

I am new in WordPress.
I have a custom post type and from that custom post type, one post will show in home page, and below that post there is a link. When visitors will click on that link, it will take them in a page where all posts of that custom post type will show with pagination.
What I have done so far.
- Created custom post type.
Called one post in home page.( Upto that it's working fine. )
Created a archive-custom.php template.
But couldn't solve that link. Php the permalink doesn't work.
Also if I try to access the archive page by mysite.com/archive-custom.php no post shows there.
Search in Google, stackoverflow, wordpress codex . But unfortunately ended up with no result.
Any suggestions on how to solve this
Better way to develop archive page for a custome postype is, copy the code from archive.php (of coarse from your current theme folder) and paste it on newly created page "archive-yourpostype.php" . Then start tweaking on the code.
From your other post, your post type is called latestnews. When you look at the Template Hierarchy (which BTW you have to read thouroughly), you can create a custom archive page for your custom poist type. For this to work, has_archive have to be set to true when registering your post type.
Now, lets look at what is happening. You have a custom archive page, arhive-custom.php. When you directly access
mysite.com/archive-custom.php
It will fail, as it is wrong permalink structure.
Also, wordpress will look for the custom post type custom, which will outright fail, because that post type does not exist.
If your post type is called latestnews, then your archive page should be called archive-latestnews.php

how to write a plugin to show content under new tab in WordPress

I refereed several ebooks and web tutorials to write a plugin that meets my requirement. However, I am still unable to do it. All I found tutorials show how to render content as widget or sidebar content or modify the content.
I need to get data from database show the content in front end of the website but only on a particular page or tab in the site. Such as forum plugin can be configured to show under new tab.
In another word I need to create my own content type and display it in a tab. I think this is possible with wordpress custom content
I don't need to edit template files. Anybody has idea? thanks..

Categories