Yoast SEO Plugin not recognising content from the Wordpress Template - php

I have developed a Wordpress website recently and used all the contents in the template itself. And all the pages and posts fields of WP admin is empty lacking content.
So my content is present in my template and not in the post and pages field.
I used Yoast SEO for this website and when checking with pages in WPadmin. No content is recognized and thus my SEO score is very low. But my content is present in the template which will be displayed in live also.
Example: I want to optimize home page and let the content be 300 words present along with template itself. No when i use Yoast plugin it is not recognizing the content from the template and says: " there is low volume of content in the home page" like this.
Can any one suggest me in solving this.
thanks

Yoast SEO can only give you a score based on DB content that it can read. That being said, just because Yoast SEO can't see your content doesn't mean that search engines can't. Unfortunately, unless you get your content out of the template and into WordPress, your Yoast score will never improve.
I'd recommend (if possible) to try to get that content into WordPress. It's just not best practice to hard-code content into template files. Consider using Custom Fields if you have specialized content that won't work in the WYSIWYG.

Related

Yoast Plugin Won't Detect Content from Shortcode in a Custom Plugin

I have created a pretty simple shortcode that contains html and php and wrapped it between the following code and used the shortcode inside a WordPress post. I went ahead to create custom plugin for which contains the shortcode.
I am having a challenge whereby the Yoast plugin is unable to detect the content of the shortcode. I know the shortcode is working perfectly, it's just that Yoast won't pull the right word count. The shortcode really contains a basic select query that fetches data from the database.
I found an article that mentioned Yoast only detects content that goes into the default WordPress editor and may not detect content from themes and plugins unless the developer adds the functionality. I'm the one doing this even as I learn.
The shortcode template I'm using:
function test_shortcode() {
ob_start();
....
return ob_get_clean();
}
add_shortcode( 'myshortcd', 'test_shortcode' );
Is there some code I need to add to the basic shortcode to get this to work?
Thanks.
This is not something that is super easy to do because it requires tapping in to Yoast's javascript API. Here is the article explaining how to do it:
https://developer.yoast.com/customization/yoast-seo/adding-custom-data-analysis/
Yoast used to have a backend hook for this, but now it's all handled on the frontend.
An alternative approach would be to use a third-party service that scrapes the content as its rendered, which ultimately is going to give you better content analysis anyway. They aren't always cheap services though. Here's one our SEO team uses:
https://www.clearscope.io/

Add additional pages to wordpress yoast seo sitemap xml programatically

I have a stragne question, I have been gogoleing for a while, but have found no answer.
I have a Wordpress site where the Yoast Seo plugin has been installed, titles, descriptions have been added, I could also manage to change the title tag, canonical url generated by it with the wpseo- filters.
The sitemap xmls are also generated fine, but I would need to add additional pages to it.
We have a search page on the site, we search by a rental custom post type.
Rentals can be searched by location.
The search page is eg.: /rentals.
We have found, that there are several sites (I can show you one in hungarian, but I'm sure you will get it) where the search results are indexed by google.
Like this one:
https://www.trivago.hu/?iSemThemeId=8302&iPathId=36103&sem_keyword=hotel%20p%C3%A1rizs&sem_creativeid=187836310244&sem_matchtype=b&sem_network=g&sem_device=c&sem_placement=&sem_target=&sem_adposition=1t3&sem_param1=&sem_param2=&sem_campaignid=242651542&sem_adgroupid=15360737662&sem_targetid=kwd-4821159859&sem_location=1007624&cip=3612001012&gclid=CjwKEAjwoLfHBRD_jLW93remyAQSJABIygGpWkl9XD9HJ7G8ZC7NbJ93ygmeFVxpZcici062NnMlgRoCkNfw_wcB
You get to this page if you search hotels paris. If you have a look at this page, this is already a search result, search parameters are set.
Now we would like to do the same with the Wordpress site.
I have done a redirection for the urls:
/rentals/budapest
/rentals/hungary
... there are more locations.
so they go to the rentals page, where I set the search parameters, I have changed the canonical urls of these pages, but I would like to add these pages to the xml sitemap also.
The problem is that these page do not exist in the database.
Is there a filter that I coul use to add these pages to the sitemap.xml in Yoast Seo plugin?
Has anyone done a similar thing in wp?
Any help is appreciated, thank you!
I have found the answer!
There is a wpseo_do_sitemap_ filter, I had to use that one. Also, This filter only created a custom sitemap, I also needed the 'wpseo_sitemap_index' filter to add my custom sitemap xml to the sitemaps index page.
Detailed solution was found under this link!
https://gist.github.com/mohandere/4286103ce313d0cd6549

Make special pages from WordPress theme?

I'm trying to figure out how a certain WordPress sets things up. I'd like to have a special page where I could make WP calls and interact with the theme, without affecting anything else.
I just making test.php and putting it into my theme's folder, but that doesn't work.
#Eliran provides one possible option, but you could also add a page in the back-end of WP, just make sure it has the slug 'test', and change your 'test.php' filename to 'page-test.php'. If you're worried about the public seeing this, set the page visibility in the admin to 'private'.
Edit:
to move your understanding along a little further also, you should review the way that WordPress determines what file to grab to render a particular URL. This can be pretty confusing to start with, so be patient if you're not familiar with it, but it's at the heart of designing WP themes. I'll link to the examples, and if you scroll down a little there's a diagram that, along with the text, will help you see how WP is 'thinking'.
http://codex.wordpress.org/Template_Hierarchy#Examples
You can see here: Page Templates
all you need to do is create a page named page-{custom-name}.php and add it to the theme folder.
and inside this php file add:
/*
Template Name: My Custom Page
*/
and than to use this page you need to go to the wp-admin, add/edit a page and chose it:
inside the php file everything you do is classic wordpress.
all this is giving you is a custom page tamplate.
Put it in your root folder. When you go to look at it, you'd look at www.mywebsite.com/test.php
It may be other ways to do this, but I rather use the rewrite API and custom query vars, to create custom routes.
A previous answer on the subject can be found here
The basic idea is to add a new url rule, catch the query var with the parse_request filter and maybe do a die or redirect to prevent the default wordpress template from loading.
I prefer this over theme templates, because with templates you need to create a page for each new url, and if that page gets acidentally deleted, that functionality would stop working.
What Pages are Not:
Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. WordPress Plugins are available to change the defaults if necessary.
Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories.
Pages are not files. They are stored in your database just like Posts are.
Although you can put Template Tags and PHP code into a Page Template file, you cannot put these into the Page or Post content without a WordPress Plugin like Exec-PHP which Read overwrites the code filtering process.
Pages are not included in your site's feed.
Pages and Posts may attract attention in different ways from humans or search engines.
Pages (or a specific post) can be set as a static front page if desired with a separate Page set for the latest blog posts, typically named "blog."
More About Pages.
In WordPress to add a new page you have to log in to the admin/backend and from the pages menu you can add a new page. In this case, you can select templaes for your page and also you can create a custom page template for that page.
You may read Createing a new page in WordPress. and custom Page template in WordPress.

Wordpress: getting latest post/image to display on an external (Posterous) site template

I have a site currently built on Wordpress. I have a requirement to pull out the "latest post" in a category (magazine issue), to allow the latest issue to be displayed in the sidebar of a Posterous blog template, either in an iframe or by other means.
What's the best way to achieve this? Shall I write a custom PHP page which queries the database directly to output the results that I want, and then display it in an iframe on the Posterous template? Or is there an easier way to achieve this?
You could register a widget to the sidebar or simply add code the sidebar.php directly. In the end, all you are doing is building a WP Query for the latest post in a category.

Using WordPress as a CMS

I am currently teaching myself WordPress and working on my own CMS site.
My site will consist of approximately five pages where the header/sidebar menu/footer will be seen on all these five pages.
Beginner here and questions are as follows:
All these five pages will consist of different content, for example, every page will have a image banner representing the menu option just clicked, for example, "About Us" on page 5, "Promotions" on page 4 etc and then some text beneath that and then possibly some images inside a carousel set up.
Within WordPress, how would I tackle this, i.e. do I just create a page in WordPress, position the banner image at the top of the page, then have a few breaks and then insert the carousel of images - is this correct?
If not, do I need to create a separate php file called aboutUs.php that has this markup and then somehow link it to a WordPress page?
On my landing page of my site ONLY (page 1), just above the footer, I want to display a div section that displays all the sponsors of the website along with a URL to click to their websites - how would I go about doing this in WordPress?
Furthermore, with my menu, how do I link my menus to point to the WordPress pages relating to that menu option?
If you use the 'default' template that comes with WordPress you could do something like this to generate different content on different pages without creating separate php files (this would go in page.php):
<?php if(is_page('About Us')) { ?>
<?php $about_query = new WP_Query('category_name=aboutus-&showposts=1');
while ($about_query->have_posts()) : $about_query->the_post(); ?>
<?php the_content();?>
<?php endwhile;?>
Essentially, in this you could just create a post and an 'aboutus' category to reference it. The page of 'About Us' (referenced through is_page()) would contain the content you wanted to display.
First, some background. Wordpress has a number of ways to display stuff, such as images, text, and query results; here's a list:
THEMES
You can modify your theme files directly to do whatever you like. This will probably involve learning a lot about PHP and the Wordpress internals, but there are plenty of books, and the Wordpress Codex to help you. You can get themes from the Wordpress theme directory.
PLUGINS
There are huge numbers of Wordpress plugins, any one of which might fit your need. Plugins will require configuration, but generally won't involve learning PHP -- just how to install and configure them. Most of the SEO (Search Engine Optimization) plugins will allow you to place custom HTML in the templates (nominally for ad placement, but you can do anything you want with it). You can get plugins from the Wordpress plugin directory.
WIDGETS
The base Wordpress software and many plugins provide Widgets. A widget is a display element that can be docked in one or more widget areas. Typically a widget will be a chunk of HTML (often an unordered list) that has the theme's style sheet applied. Widgets are often used for ad placement, navigation elements (menus, dropdowns, breadcrumbs) or to provide tag clouds, category lists, calendars, etc.
SHORTCODE
A shortcode is a macro that can be placed in a page or post, that will return a chunk of HTML. Shortcodes can take parameters that will affect what the shortcode returns. The base Wordpress software provides some shortcodes, but many plugins will provide shortcodes as a way to get more functionality without the need for widgets or theme modifications.
With all of that in mind, here's my answer(s) to your question(s):
Modify your theme to include a page template, and add your image selection code to the template. Then create your individual pages, and then select your template while editing the page.
The 'landing page' can be any page (instead of the default blog index page); create a 'home' page and a 'home' page template that includes your advertisements. Alternately, use a SEO plugin to add the ads above the footer.
I don't know what theme or plugins you use, but generally you can configure a navigation menu to work from a list of pages, specifying either which pages to include or which pages to exclude. If your theme doesn't include this functionality, I'd recommend choosing a different theme.
Look into Wordpress "page templates". The Wordpress codex can help you understand this.
If you edit a post in WP you will notice the option to use a template. That is your goal. Learn how to work with them.
Wordpress themes are composed of multiple files. One of them is the header.php file which contains the header content. The footer.php file contains the footer and the sidebar.php contains the sidebar. These are the usual conventions. They're not strict. There will be a couple of main files which include these (e.g., index.php - Used for articles, page.php - Used to display pages etc.)
If I were making a setup like yours, I'd make five "pages" (using the backend) and then customise my page.php file to present it properly. I'd still keep the header, footer and sidebar separate from the page.php file since they'd be there for pages like 404s etc. as well.
Just put something in the content of the landing page to display this.
IF you're doing theme development, the right place to look at is http://codex.wordpress.org/Theme_Development

Categories