{"id":3622,"date":"2021-07-07T14:27:44","date_gmt":"2021-07-07T12:27:44","guid":{"rendered":"https:\/\/www.knowboard.de\/?p=3622"},"modified":"2021-10-02T15:21:10","modified_gmt":"2021-10-02T13:21:10","slug":"simple-shortcode","status":"publish","type":"post","link":"https:\/\/www.knowboard.de\/simple-shortcode\/","title":{"rendered":"Simple Shortcode"},"content":{"rendered":"\n

Bonus tip: If you are using the great total theme there are a couple of basic shortcodes that it comes with. You might find them useful to adapt or change. Just have a look in this folder: „\/wp-content\/plugins\/total-theme-core\/inc\/shortcodes<\/strong>„<\/p>\n\n\n\n

Simple one Tag Example [shortcode ]<\/h2>\n\n\n\n
\/\/ Do something\nadd_shortcode( 'media_url', 'media_url_render' );\nfunction media_url_render($atts, $content, $tag) {\n\t\n\tglobal $post;\n\t$link = get_post_meta( $post->ID, 'media_link_url', true );\n\t\n\treturn $link;\n}<\/pre>\n\n\n\n

And a simple version with two arguments<\/p>\n\n\n\n

\/\/ Add Shortcode\nfunction myprefix_count_post_terms( $atts ) {\n \n\/\/ Attributes\n$atts = shortcode_atts(\narray(\n'post_id' => '',\n'taxonomy' => '',\n),\n$atts\n);\n \n$terms = wp_get_post_terms( $atts['post_id'], $atts['taxonomy']);\nreturn count($terms);\n \n}\n \nadd_shortcode( 'myprefix_count_post_terms', 'myprefix_count_post_terms' );\n\/\/use like [count_post_terms post_id='[myprefix_count_post_terms]' taxonomy='category']<\/pre>\n","protected":false},"excerpt":{"rendered":"

Bonus tip: If you are using the great total theme there are a couple of basic shortcodes that it comes with. You might find them useful to adapt or change. Just have a look in this folder: „\/wp-content\/plugins\/total-theme-core\/inc\/shortcodes„ Simple one Tag Example [shortcode ] And a simple version with two arguments<\/p>\n","protected":false},"author":1,"featured_media":3650,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3622","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemein","entry","has-media"],"_links":{"self":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3622"}],"collection":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/comments?post=3622"}],"version-history":[{"count":2,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3622\/revisions"}],"predecessor-version":[{"id":3682,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/posts\/3622\/revisions\/3682"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/media\/3650"}],"wp:attachment":[{"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/media?parent=3622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/categories?post=3622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knowboard.de\/wp-json\/wp\/v2\/tags?post=3622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}