WordPress.org

Ready to get started?Download WordPress

Forums

Smart WYSIWYG Blocks Of Content
add slug to shortcode example (2 posts)

  1. jonathan176
    Member
    Posted 2 years ago #

    Hi Coen,

    Thanks for the Great plugin! I am finding it very useful. The only thing I found lacking was the short code requiring the ID, which is hard to find. Blow is an example of how I extended your plugin to also except the SmartBlock's slug or ID.
    Example [smartblock slug=slugname]
    Example [smartblock id=postnumber]

    Hope this helps, and thanks again.

    edit to smart-wysiwyg-blocks-of-content/includes/class-swboc-front.php

    function swboc_shortcode( $atts ) {
    	extract( shortcode_atts( array (
    		'id' => '',
    		'slug' => '',
    	), $atts ) );
    
    	$content = "";
    
    	global $post;
    	$temp = $post;
    
    	if ( $id != "" || $slug != "" ) {
    
    		if($slug != ""){
    			$args=array(
    			  'name' => $slug,
    			  'post_type' => 'smartblock',
    			  'post_status' => 'publish'
    			);
    		} else {
    			$args = array (
    				'post__in'  => array ( $id ),
    				'post_type' => 'smartblock',
    			);
    		 } // end if slug
    
    		$swboc_posts = get_posts( $args );
    
    		remove_filter( 'the_content', 'prepend_attachment' );
    
    		foreach ( $swboc_posts as $post ) {
    			$content .= apply_filters( 'the_content', $post->post_content );
    		}
    
    		add_filter( 'the_content', 'prepend_attachment' );
    	}
    
    	$post = $temp;
    
    	return $content;
    }

    http://wordpress.org/extend/plugins/smart-wysiwyg-blocks-of-content/

  2. hurstm78
    Member
    Posted 1 year ago #

    I went into the editor for plugins and inserted the code listed above in the file
    smart-wysiwyg-blocks-of-content/includes/class-swboc-front.php

    Then I entered the code [smartblock id=<SWBOC_post-name-for-the_smart_block_I_created_using_underscores>] on the page however nothing new appeared on the page.

    I am trying to put widgets in the middle of a page so I can have static content on a front page.

    Any thoughts?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic