Wordpress display category posts on different page - php

I have a posts category setup called Portfolio. Currently the URL is www.example.com/category/portfolio, how would I display the same page but the url be www.example.com/portfolio?
Maybe I can create a new Template for that page, but how would I display the same results? I was thinking about there might be a URL alias setting?

Creating a template for this is a solution, but I think it will only work efficiently if you have small number of categories.
Try using:
http://wordpress.org/plugins/wp-no-category-base/
http://wordpress.org/plugins/top-level-cats/
I think there are other available plugins to do this.

Related

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

Populating a WordPress Page with posts from a Category or Tag

I have a WordPress for my science journalism blog and I would like to add a page that contains a subset of the blog posts. For example, having a page populated by a certain category (i.e. review articles) or tags (i.e. physics).
There seems to be a way to do this by making a new php page, but I am not sure how to get to a blank template to add the code base.
Alternatively, I would prefer having a way to do this without having to mess with the code at all. Any help would be much appreciated. Thanks!
This happens automatically with WordPress; read the docs:
When a viewer clicks on a link to one of the Categories on your site,
he or she is taken to a page listing the Posts in that particular
Category in chronological order, from newest Posts at the top to
oldest at the bottom.
Read https://codex.wordpress.org/Category_Templates
You don't have to make a category or tag template page, but you can if you want to. This is theme-dependent; your theme may already have different archive page templates.
The URL for a category or tag archive page will be:
example.net/category_base/category_name
example.net/tag_base/tag_name
Read https://codex.wordpress.org/Using_Permalinks#Category_base_and_Tag_base
Go to Appearance>Settings>Reading to set number of posts per page and either excerpt or full post.
I think you should be able to get at a category by going to http://example.com/category/mycategory
And to tags by visiting http://example.com/tag/mytag
You should be able to add categories to the main menu, and add tag pages via a custom link OR use a tag cloud?
Hope this helps.

Wordpress: Adding meta values like title and description for Pages from custom database

I have a plugin that creates plugin specific database table rows that then are turned into pages. I have got this work with URL redirect and have been able to lay out the page. Now I am having some problems.
Problems:
Creating header title for the page. It currently shows page not found.
Creating description for meta SEO. Meta description is currently blank.
Showing these custom created pages to be added in WP menu.
I know these are not pages, and I have lost most of the wp functionality by doing this and not using custom post types but one of the main requirements of the clients was that the database have separate tables for their data.
I need some help or reference regarding these problems. Links for examples and articles would do or any free plugins that actually do this.
I'd really appreciate the help.
As you mentioned your self, using your current technique you will not able to take advantage of WordPress in real sense. You may use custom posts and then use wp cron to copy get the data from there to your own table.

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.

Custom URL rewrite in wordpress

I am trying to achieve a custom URL structure with Wordpress. Basically, my site functions as my blog and my portfolio. I want to have an "Articles" section and a "Portfolio" section. I want the articles to display on the Articles page, and the portfolio on the Portfolio page. Should be easy, except on top of that I want custom URLs...
I want the URLs setup like this:
Articles page:
http://mydomain.com/discusses
Specific article:
http://mydomain.com/discussed/%postname%
Portfolio page:
http://mydomain.com/does
Specific design:
http://mydomain.com/designed/%postname%
I can figure out how to do only one rewrite of this type, but WP doesn't have built in functionality to do both. I'm just wondering where I should start or what I should do...
The problem also becomes, I want to retain category functionality in both areas, so maybe it needs to be achieved with Custom Fields? and add a new rewrite rule based on the custom field of a post? I have idea where to start...
Thanks for any help you can give.
This actually isn't that hard to do. I'll go down, page by page, what you would need to do to achieve this.
Articles Page
Create a new template in your theme folder (/wp-content/themes/your-theme/) called discusses.php and just add the following content:
<?php
/*
Template Name: Discusses Template
*/
?>
You don't need any more content. Go into the Pages section of WordPress Admin and create a new page called Articles page and set the URL to be /discusses/. Set the template of this page to be Discusses Template. Now, go into the Settings → Reading section in Admin and set the Posts page to Articles page. Now all your blog posts will appear under the URL /discusses/
Specific Article
The easiest way to have all your articles appearing as /discussed/title is to rename the default category (in Posts → Categories) to discussed. Then set your permalinks to be:
/%category%/%postname%/
This will render the links you need for each post.
Portfolio Page & Specific Design Page
Assuming this will be some kind of custom design, the easiest thing to do would be to create a custom template and Page in the pages section, as you did for the articles page, and throw your custom HTML and CSS into that. I would then set each specific design page to be a child page of that in the pages section. You can use the WPdb classs to make custom queries to populate the Portfolio page.

Categories