Wordpress Meta Tag Task

I am currently trying to create a website for a television show, and due to certain Wordpress restrictions, this is becoming a problem.

However, I got around this by implementing custom meta fields in the functions.php file, now my problem is that I need to actively create new fields when sending information to the current field. For example, custom metabox names (Episode Name="This is It") (Episode Number="1") (Season Number="5")

Instead of creating all the boxes from the very beginning, I would like to use Javascript (jQuery) or any solution to automatically create a new set of these three fields
(Episode Name="") (Episode Number="") (Season Number="") so I can just enter new information as they become available. Thank you in advance for your help!

Note. . I spent too much time on Wordpress to just switch to other cms, so at the moment this is not an option.

+4
source share
3 answers

From what I understand about your question, you are looking for a simple solution to automate the input process. I have a general idea of ​​what you need to do as I had to do something similar on the brochure website.

I tried to answer your question using jQuery, but I find that it increases the amount of text input needed to create your message, but, unfortunately, there is no fully automated method for its execution, but I hope a solution will be provided below.

I first found the following plugin: Types is the complete solution for custom fields and types here: http://wordpress.org/extend/plugins/types/

This allows you to create custom meta-fades when creating a new post / page. Custom feilds are added with the perfection "wpcf-" and then the field name, for example. "Episode Name" becomes "wpcf-episode-name" in the database.

The following is the wordpress get_meta function:

 function get_specifications(){ if ( $keys = get_post_custom_keys() ) { echo '<div class="entry_specifications">'; foreach ( (array) $keys as $key ) { $keyt = trim($key); if ( '_' == $keyt[0] ) continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); //remove "wpcf-" $key = str_replace('wpcf-','',$key); //convert "-" to a space " " $key = str_replace('-',' ',$key); //check if it has a value, continue if it does, skip if it doesn't: if ($value <> ''){ echo apply_filters('the_meta_key', " <div class='meta_wrapper'> <div class='meta_title'>$key</div> <div class='meta_value'>$value</div> </div>\n", $key, $value); }; } } // echo '</div>'; comment out and remove the line below if you are not using floats in your css echo '</div><div class="clear"></div>'; } 

In my page.php (or your template-page.php) I added the following code when / where I want the meta to be created:

 <?php //check to see if there is meta data, as you only want the meta data on TV Program pages $met_check = get_post_meta($post->ID, 'wpcf-features', true); if ($met_check <> ''){ //if it has a value, spit out "About EpisodeName" ?> <h2 class="post-title clear">About <?php echo $title ?></h2> <?php //perform the function from functions.php and return results: echo get_specifications(); } ?> 

I designed the result with the following CSS:

 .meta_entry { clear:both; } .meta_title { float:left; text-transform:capitalize; width:200px; } .meta_value { float:left; width:480px; } 

Hope this helps a buddy!

+2
source

There is a great wordpress plugin called Pods , which can be a viable solution.

+2
source

Source: https://habr.com/ru/post/1382812/


All Articles