Note that there are some explanatory texts on larger screens.

plurals
  1. POin WordPress when i create a new page i need it to category with the same title
    primarykey
    data
    text
    <p>i have a new page type called QQQ so whenever a QQQ page is created i need a new category to be created along with it with the same name as the QQQ page.</p> <p>however this is only for QQQ pages and no others.</p> <p>u see the template calls posts in the same category as the QQQ pages title.</p> <p>any one got any ideas?</p> <p>all help is greatly appreciated im really at a stand still here</p> <p>"Are you creating posts programmatically or you just don't want to have to create the category manually when you add a post in the admin section? I'm asking because more context often results in better solutions." – Calle</p> <p>exactly~! creating the category manually leaves too much room for human error, say if client (A) creates page QQQ then procededs to create the category but accidentally creates category QQ0 then products assigned to category QQ0 will not display on the page QQQ.</p> <p>so i want the page creation to automatically create the category as well to avoid future distress calls.</p> <p>ANSWERED!</p> <p>hey guys i finally got it to work like this :)</p> <pre><code>function add_catalog_category($post_id) { global $post; $title = get_the_title($post-&gt;ID); $cat_ID = get_cat_ID( $title ); //If it doesn't exist create new category if($cat_ID == 0) { $cat_name = array('cat_name' =&gt; $title); wp_insert_category($cat_name); } //Get ID of category again incase a new one has been created $new_cat_ID = get_cat_ID($title); } </code></pre> <p>so yeah... that seems to be working now i just have to do the inverse</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload