How to embed page content in a blog post

Create a shortcode to embed the content. This will always be synchronized. Sample code from an older project. Just updated. 🙂 GitHub: https://gist.github.com/3380118 · This post in German (auf Deutsch) on my blog. <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Embed Post Shortcode * Description: Embed any page, post or custom … Read more

How to get shortcode working from custom meta field

You can do this by using ‘the_content’ filter. That way, WordPress will treat the content as it was came from the editor field and execute all the shortcodes: <?php $meta = get_post_meta($post->ID, ‘intSlider’, true); ?> <div id=”sliderWrap”> <div id=”slider” class=”floatLeft”> <? echo apply_filters(‘the_content’, $meta); ?> </div> </div> Just be careful because it will wrap the … Read more

Allowing for multiple template views on the Gallery Settings page when using the Visual Editor

It appears that the templates live in script form <script type=”text/html” id=”tmpl-my-custom-gallery-setting”> To render the above template would require wp.media.template(‘my-custom-gallery-setting’)(view) Since we’re replacing the template: logic then all we need to do is store a list of template IDs. if (!wp.media.gallery.templates) wp.media.gallery.templates = [‘gallery-settings’]; wp.media.gallery.templates.push(‘my-custom-gallery-setting’); Then loop through all available views wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({ template: … Read more

shortcode outputs first before the page content [duplicate]

I guess you’ve echoed the result of shortcode callback function rather than returning them. Please check here: http://codex.wordpress.org/Shortcode_API Shortcodes are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output). you need to return the output that will be added … Read more

using html as shortcode attribute

Pass just the element names and convert them to tags in your shortcode: [irt_top_posts post_type=”showcase” container=”div” number=”10″] In your callback: $return “<$container>$return</$container>”;

How to display random users with avatars

I am not sure why your query is returning more IDs than necessary. The $args for get_users look correct. By default get_users does not support orderby=rand, but you can overwrite that option. See below: function random_user_query( &$query ) { $query->query_orderby = “ORDER BY RAND()”; } // Usage: [random_users how_many = 3] add_shortcode( ‘random_users’, ‘display_random_users’ ); … Read more

Short code to display a loop

There is a multitude issues wrong with the above. For one, post_parent in the query arguments needs to be an integer. You’re assigning it a string. A number of your calls to wordpress functions, such as the_excerpt() and wp_reset_query() are missing ending semicolons. $atts is an associative array of attributes for the shortcode. If you … Read more

Implement If-ElseIf-Else-EndIf with short codes

Having a look at your SO post, seeing the CF Tag output, then seeing what you’re trying to attempt here with shortcodes is, as Otto said, going to be an incoherent mess. There already exists plugins that allow you to write PHP logic amongst your post content, and the following Allow PHP in Posts and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)