[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[WordPress] Display related articles in conjunction with CPT UI! YARPP modification memo

Hello.
I'm Mandai, in charge of Wild on the development team.

Have you noticed that related articles have recently been displayed on Beyond Co., Ltd.'s technology blog?
As the number of articles has increased, I think this is a perfect way to increase the circulation rate of the site by linking to related articles, and I think it is a major method.

Our homepage is completely managed with WordPress, and we
initially tried implementing Similar Posts with multiple categories lined up, but it didn't work as expected, perhaps because it wasn't compatible with the CPT UI. I didn't.

In this article, I would like to take advantage of the CPT UI settings and look at YARPP settings one by one to retrieve related articles as desired.

First of all, install

We will proceed with the discussion assuming that CPT IU has been installed in advance and that multiple categories have been registered.

Next, we will install YARPP, which you can also find immediately by searching for YARPP from the plugins on the management screen.
There was a warning that the latest version has not been tested with WordPress versions, but it seems to be working fine in the end, so you don't need to worry too much.

 

Register the category you want to publish related articles on YARPP

This part is the key to the settings, but since there is no setting section on the settings screen, we will modify the source code.

First, display the list of custom post types registered in "Refistered Types/Taxes" of the CPT UI in the side menu of the management screen.

Information for each Post Type will be displayed, so find the "Get code" link in the category you want to display (in the case of our site, blog) and click on it.

2016-10-03_16h09_57

At the link destination, the code to copy and paste to functions.php will be displayed, so copy it.

2016-10-03_16h11_32

The code prepared for the blog is as follows.

add_action( 'init', 'cptui_register_my_cpts_blog' ); function cptui_register_my_cpts_blog() { $labels = array( "name" => __( 'Blog', '' ), "singular_name" => __( 'Blog', '' ) , "menu_name" => __( 'Blog', '' ), "all_items" => __( 'Blog', '' ), "add_new" => __( 'Add new', '' ), "add_new_item" => __( 'Add blog', '' ), "edit_item" => __( 'Edit blog', '' ), "new_item" => __( 'New blog', '' ), "view_item" => __( 'Show blog', '' ), "search_items" => __( 'Search blog', '' ), ); $args = array( "label" => __( 'Blog', ' ), "labels" => $labels, "description" => "", "public" => true, "publicly_queryable" => true, "show_ui" => true, "show_in_rest" => false, "rest_base" => "", "has_archive" => true, "show_in_menu" => true, "exclude_from_search" => false, "capability_type" => "post", "map_meta_cap" => true, "hierarchical" => false, " rewrite" => array( "slug" => "blog", "with_front" => true ), "query_var" => true, "menu_position" => 5, "supports" => array( "title", "editor ", "thumbnail", "revisions", "author" ), "taxonomies" => array( "category", "post_tag", "com_cat" ), ); register_post_type( "blog", $args ); // End of cptui_register_my_cpts_blog() }

Next, go to "Edit Theme" in Appearance and paste the code from earlier into functions.php.
It seems that you can paste it anywhere, so paste it at the end.

2016-10-03_16h12_18

After pasting and saving, the registered blog will appear as a setting item on the YARPP settings screen, so
check it out.

2016-10-03_16h15_33

At this point, related articles were displayed on each blog, so the settings were mostly completed, but
there were some parts where the existing layout was broken, so we will also modify this as well.

 

Where's CSS?

Files related to YARPP are stored under "path/to/wp-content/plugins/yet-another-related-posts-plugin" (path/to is the absolute path to wp-content).

Since I didn't feel like making any major changes, I decided to just delete the "yarpp-related" class in the div tag that largely encloses the area where related articles are displayed, and
leave the rest to the existing CSS.

This part is in a file called YARPP_Core.php.
In the plugin editor, select "Yet Another Related Posted Plugin", search for YARPP_Core.php on the left and click it.

In the version I modified (4.3.1), I just deleted the string on line 1105.

If you search for yarpp-related, it will come up right away.

$output .= "

2016-10-04_10h00_33

Now, the CSS related to yarpp will no longer be applied, so I think the design that follows the layout of the site will be applied.

After setting up the articles and categories to be associated, the settings are complete.

 

I want to delete the score display for association

I deleted the score information for association because I didn't think it was necessary.
This process is written in the file "yet-another-related-posts-plugin/includes/template_builtin.php", so I think there will be no problem if you delete or comment out the relevant part.

2016-10-03_16h57_21

That's it.

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
836
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also fortunate to be able to do a lot of other work, including marketing.
Furthermore, my portrait rights in Beyond are treated as CC0 by him.