Removing / Disabling Wordpress date and /blog links - php

Solution:
The problem was actually SEO Yoast. It creates "Archives" for posts and authors, creating a whole load of crap on the website.
The current template for our wordpress website originally was html only.
A guy we hired some time ago, did the transfer so to speak, but there are some problems.
At the moment the website contains "www.website.com/blog" and various "www.website.com/2018 or /2018/06" links that google does it's damnedest to index. Some of the links return a 404 occasionally as well.
Because we do daily blog post's everything is naturally copied over to those "/blog" pages. The results is 52% duplicate content (according to Siteliner)
I'm writing here looking for advice, because I don't know how to get rid of them or how to manage them to reduce the SEO related impact. I also didn't find post relating to this specific problem.
(example of the problem "multiorders.com/2018/07/page/2/" )
Our post links are set to website.com/sample-post, someone had suggested adding a "RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourwebsite.com/$3" into the .htaccess file.

I can tell you the basic structure to avoid the Duplicate content issue and the URL structure issue. Both are really important and can say main factor for Seo purposes.
Structure:
First one, Create a blog page (Already created on your website). On that page there must be shown the all blog posts that you have entered in the admin panel at POSTS menu. The lists of all blogs www.example.com/blog here as you said. In that page there should me pagination that means if you are showing 10 posts per page then the 11th post will be on the www.example.com/blog/2 and so on. (acceptable foe seo purpose).
Secondly, If someone clicks on the post or Read more button it should redirect the
single blog www.example.com/blog-post-name (perfect for seo).
To change the permalink (URL Structure) you have go to the admin settings menu -- permalink menu-- change to post name and Save.
Note: Take a backup before applying
Any questions, please ask..!!

The problem was actually SEO Yoast. It creates "Archives" for posts and authors, creating a whole load of crap on the website. As soon as I disabled those features all the extra pages vanished. Now all I need is to wait for Google to catch up.

Related

Best way to share content between a Wordpress site and a Drupal site

I will try to be clear but if you need more information please do not hesitate.
A site approached me to make a partnership together. They want to create a new section on their site, say a "blog" section. The goal is to post my blog post on their site, in this new section, without having access to their admin.
So I need to set up something to be able to automatically share the content I post on my site with their site. My site is on Wordpress and their site is on Drupal.
For now I see 2 possibilities, but tell me what you think and if there is better to do.
First possibility: Create the page /blog and all the articles (ex: /blog/article-title) on my site, then set up a reverse proxy to redirect their request to my server. I have no experience with network setup so maybe I am completely wrong. But even if it works, I don't know how to fetch only post content (not header, footer) and change all urls.
Second possibility: Create a Drupal module, which they will have to install on their site, which creates the page /blog and the custom content type named "blog" when it is activated. And then use the feeds module to get the content from my wordpress feed and create a blog post for each post in the feed. With this solution, I won't have any header or footer problem, and the urls to the articles will be generated dynamically.
Every advice will be usefull. Thank you.
IMO, the easiest way to do that is to use the Wordpress REST API.
You could get all posts with this https://yoursite.com/wp-json/wp/v2/posts and get a specific post with https://yoursite.com/wp-json/wp/v2/posts/:id
full doc here : https://developer.wordpress.org/rest-api/reference/
I would advise you to use the second possibility, cause there are already several drupal moduls in the wild the read and import feeds from other sites.
Even more, WordPress will provide your posts also in oembed-format. With this you can use this Drupal Modul: https://www.drupal.org/project/soembed
You vcan adjust this modul to allow content from your website and display it on the Drupal installation.

Tie Wordpress Blog into single website login session so login required when blog selected in menu

I have found multiple postings with similar phrases but all too specific to their issue and not addressing this...
Most of the website requires a login session. I have built a custom plugin for WordPress to handle my CMS needs, etc. I have included a blog in the website. However, my issue is... How do I require login when "blog" is selected on the menu. AND I do NOT want to show WordPress anything. I want the blog to look like the rest of the site.
Basically I want to "nest" the blog in my website with one required login session. I have the menu item "blog" set as a category so as to pull the WordPress pre-built functionality. So this is the only item I am not able to php a login session as there really isn't a page to do so.
I have read several things. But finding them a bit confusing. Many say to change the wp-config.php but I am not comfortable with changing core files within WordPress. What am I missing or misunderstanding?
UPDATE:
Would changing the menu selection to a "page" instead of "category" and insert php file within that page with a redirect using header('Location:mysite.com/blog_files (of course after session verified) to redirect where WordPress has stored my blog? Is this a viable work-a-round?
You can use your wordpress as API point. Wordpress comes with REST API. So what you can do is get all posts after certain action. Then parse them in html.
There are 2 things to keep on mind.
1st is that everything on wordpress is post.
2nd is that to change certain parts of how api works you add filters to functions.php.
Hope I was helpful.
UPDATE
I have successfully "nested" my blog into my website so that login session is required. Changing the menu selection to a "page" instead of "category" and insert php file within that page with a redirect using header('Location:mysite.com/blog_files (of course after session verified) to redirect where WordPress has stored my blog files. This was quick and easy. However, it still requires WP login to participate in the blog. :(

Revising WordPress URLs with .htaccess

On my WordPress installation, I have a blog living at http://domain.com/blog. Each individual blog post lives at http://domain.com/post-title.
So that I can more effectively segment page traffic in Google Analytics, I would like to revise my permalink structure so that individual posts live at http://domain.com/blog/post-title.
The challenge, however, is that I also have several pages at http://domain.com/page-title. I do not want to impact those page URLS.
Is there a way that I can modify the permalink structure only of my blog posts? If so, is it then possible to set a rule within .htaccess to redirect from old permalink structure to new?
I believe what you want to accomplish can be easily fixed by visiting the Settings > Permalinks page in wp-admin.
Towards the bottom of the permalink selection radio items, you can choose "Custom Structure", then enter a value like blog/%postname%/
This will have the effect of prepending all of your post slugs with 'blog', while leaving pages' URLs untouched.

Make Wordpress use the page instead of category

I did a great amount of research and came across some solutions like this:
https://wordpress.stackexchange.com/questions/106042/force-wordpress-to-show-pages-instead-of-category
But still it isn't exactly what I'm looking for. First of all let me explain the problem.
I made a page /blog/ and a category 'blog' both make use of the permalink /blog/, disabled the /category/ permalink so the SEO will be correct.
The solutions I came across didn't match the following requirements:
Not using 301 redirects
Disable the /category/ use within Wordpress.
Also make it possible to only replace category when a page id uses the same slug.
I simply like to tell Wordpress to display the page instead of the category.
Why don't you just edit the category template?
Because the page I created uses Visual Composer (Post Masonry Grid) so I can't simple move the design.
Why don't you just use redirects?
I would like to but the permalink of the blog is the same as the page (SEO purpose.)
I know it's a few years later with no solution, but I had the exact same problem you described on one site that was working in other sites. So I did some research on what was different and to help others should they run into the same issue.
Background
example.com is the domain
I have a WP page called "foobar" with content
I have a WP post category called "foobar"
I have a WP post entitled "fun things to do with foobars", and the category is set to "foobar"
Expectations
When I go to example.com/foobar, I want to see the page about foobars, not a WP category page that shows all blog posts with that category.
When I go to the blog post about fun things, the URL is example.com/foobar/fun-things-to-do-with-foobars/
Setup
Here's my setup (it does not require any additional plugins or code edits)
A couple of installed plugins are WP Rocket and Yoast on which I'll focus in this thread.
WP Dashboard->Settings->Permalinks
Select "Custom Structure" and enter /%category%/%postname%/ in the field
On the same page, change "Category base" to a single dot. "." (no quotes, just a single dot/period/full stop
I have Yoast installed, which I had set up to override the permalink settings, but I believe this messed up my task at hand.
WP Dashboard->SEO->Advanced->Permalinks(tab)
"Change URLs->Strip the category base..." = Keep
Then you need to clear the cache. I use WP Rocket for caching, so I flushed the cache and everything now works the way it should.
Edit: make sure you save your changes after steps 3 and 5
I know this topic is old but question is still important.
I will use blog example.
This method is code free, WP native solution. One caveat is that you cannot translate "blog" slug, so this method is only for one language if you don't need to have different words/slugs for other languages.
Create page with slug "blog". Or whatever you like. It must match word you put in next step as base: blog = blog it this example.
Set permalink structure in settings to: /blog/%category/%postname%/ (/ trailing slash on the end is your preference)
Use SEO plugin like Yoast or Seopress Pro (or any other
method) to remove /category from URL.
Go to Settings -> Reading -> "Your homepage displays" section -> "A static page (select below)"
Set your static page for Homepage
Here is the magic: set Posts page to your "Blog" page.
Flush permalinks by visiting and saving settings on Permalink page (without any change).
Then you will get proper URL: /blog/yourcategory/single-post-title/
Breadcrumbs will work, all categories will be hierarchical, and /blog will work as page instead of category.
Most importantly, when you go to your category page you will get /blog/yourcategory URL and it will work as archive page. When you visit single post, then also you get URL /blog/yourcategory/single-post-title/
Breadcrumbs from Yoast should work. I use Seopress Pro and breadcrumbs works like a charm (you have to go to breadcrumbs setting page and select categories for posts and posts for categories and tags if you need them).
If you do it without including /blog in your permalink setting it will still work, you will get page instead of category with proper url for categories, but single post will be /yourcategory/single-post-title.

Why do Wordpress rewriites seem to work differently for posts vs pages?

Because you can't duplicate a slug in WordPress, we are getting round it by giving unique slugs to some sections of our website but rewriting the urls to get the desired structure:
add_rewrite_rule('product1/faqs/?', 'index.php?name=product1-faqs', 'top');
add_rewrite_rule('product2/faqs/?', 'index.php?name=product2-faqs', 'top');
This enables us to have an "faqs" directory within each product but of course the actual slug of that page is much different.
I've noticed that if you hit "product1/faqs/" in the browser, it successfully displays the content of "product1-faqs" but keeps the url as product1/faqs/ (which is desired) but only if it is POST.
If I try this same technique but on a PAGE, the browser URL flicks to "product1-faqs" (undesired!)
Why is that? I don't want have to limit ourselves just to posts for the sake of rewrites working as desired...

Categories