Nestle post type under category WordPress

I know this plugin isn’t supported by WPMU but I was wondering if I could get help figuring this out.

I’m using a plugin called Easy Recipe that creates posts when someone submits a new recipe and I’m looking to making these posts become nestled under the category “recipes” and here’s the code that controls the posts as I’ve found.

<?php

// TODO - figure out how to get this more robustly
require_once ('../../../wp-load.php');
require_once ('../../../wp-admin/includes/post.php');
require_once ('../../../wp-includes/post.php');
require_once ('../../../wp-includes/formatting.php');
require_once ('../../../wp-admin/includes/media.php');
require_once ('../../../wp-admin/includes/file.php');
require_once ('../../../wp-admin/includes/image.php');

nocache_headers();

$id = media_handle_upload('file', $_REQUEST['postID']);

if (is_wp_error($$id)) {
// TODO
// esc_html($id->get_error_message()) . '</div>';
}

$post = get_post($id);

$filename = esc_html(basename($post->guid));
$title = esc_attr($post->post_title);
// $post->post_mime_type
// $meta = wp_get_attachment_metadata( $post->ID );

$link = '';

// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id","imageLink" : "' . $link . '"}');

I’m just trying to figure out how to make the url read mydomain.com/recipes/the-post-title rather than mydomain.com/the-post-title

The reason for doing this is that I’m using a custom menu to only show on posts that are created using the Easy Recipe plugin.

  • Imperative Ideas
    • HummingBird

    Ok slow waaaaaaaaaay down.

    Don’t go hacking the WP core with your own custom mods. It will bring you only pain with a side helping of humility the next time WordPress runs an update on you. This is specifically what plugins are designed to prevent. If anything you want to unhook the core function then hook a new version of it back in. If you have no idea what I’m talking about then you probably shouldn’t have your nose in there unless you want it getting bitten in a bad way.

    In reality, your solution is much, much simpler.

    1. Go to your WordPress admin

    2. Settings => Permalinks

    3. Select “custom structure”

    4. Enter exactly this: %category%/%postname%/

    Yes, include the trailing slash.

    Now navigate to your recipes.

  • Weird Mike
    • Site Builder, Child of Zeus

    I take it you didn’t read the part about

    I’m using a plugin called Easy Recipe that creates posts when someone submits a new recipe and I’m looking to making these posts become nestled under the category “recipes”

    I didn’t say anything about the WP core or adding custom mods.

    I asked about making the plugin (which the code that controls the posts has been posted) to be able to post under a category rather than making it a global post.

    I’ve been all over the net asking about this.

    Could it be as simple as maybe adding $post = get_post($id) post-style-'wp_get_category_ID()' or something?

  • Imperative Ideas
    • HummingBird

    My apologies, “nestled under” isn’t a technical term in programming. I did not mean to misunderstand you or cause additional frustration. The script section, if part of the plugin, looks like it was copied verbatim out of the core functions for displaying the editor.

    Are you saying that the plugin does not automatically assign a category to the post and you want to change this behavior?

    Most plugin authors are not very good at creating hooks and actions, which makes their stuff a real bear to change without going off the reservation with regards to future update compatibility.

    In order to find an answer for you, we should probably clarify the question.

    If what you want is for all auto-posts to be added to the “recipes” category then I should be able to poke around the plugin code tomorrow (when it isn’t almost 3am).

  • Weird Mike
    • Site Builder, Child of Zeus

    Are you saying that the plugin does not automatically assign a category to the post and you want to change this behavior?

    It assigns the category, but when you view the post it’s not longer following the category it was created under. The url appears as mydomain.com/recipes/name-of-post before you click on the post and when you click on the post it reads mydomain.com/name-of-post and I want it the posts made by the plugin to always remain under that category. Trying to make a custom menu appear for anything under “recipes” (which I’ve done using php) but the posts themselves don’t want to stay under “recipes”. I’ve done something like this with creating just a regular blog post before but since the users will be making recipe posts I want those recipes to be accompanied by that menu. It’s a real pain in my lack-of-php-knowledge butt

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.