How to target smartlist in custom function?

Posted in: Newspaper
Post count: 28

Hey guys-

I’m using a few custom functions to manipulate the output of some posts. I’d like to able to target posts that use the smartlist format.

What do you suggest as the best way to do this?

Is there an identifier I can add to this code block (or some other workaround)?

if(is_single())

Thank you!

Post count: 23312

Hello five40,

I am not very clear about what you want to achieve but if you want to make a reference (targeting) to some posts you can use the is_single() condition using the post ID. For getting the post ID, you have to inspect your desired post with your inspector like this -> http://screencast.com/t/pNXVqPfR78Hc For more references about this condition, please check here -> https://developer.wordpress.org/reference/functions/is_single/ Please notice that involve custom work and if you want to make some customization through code and you are not aware of the steps in this regard, please consider hiring a freelancer/developer to help you because we cannot provide customization services at the moment, sorry!

Thank you for your understanding!

Post count: 28

Hi Catalin-

I am already using is-single(). I’d like to specifically reference ONLY posts that use the SmartList format.

This is pseudo code…

is-single(format="smartlist")

I know that won’t work but if you could point me in the right direction I’d be grateful.

Post count: 23312

Hello five40,

If you want to check your smart list post, you should try to use the similar code which is using in our td_module_single_base.php, like this -> http://screencast.com/t/PwoI2IJND For example, you can add this check in loop-single-1.php (if you are using the post template 1), like this -> http://screencast.com/t/psNBdso1Z

Hope this helps!

Thank you for your understanding!

Post count: 28

I am finally getting around to making my customizations.

The example you provided is very helpful and I think I am close.

However, I am attempting to add this to a plugin and it’s not working.

The purpose of my plugin is to add the content of one specific post to the end of all the posts on the site. I’d like to modify this so I can add choose one post to add to smartlist articles and another post to add to articles that are not smartlists.

This is my existing code that works on all articles:

function wmhb_filter_content1($content) {
	
	if(is_single()) {
		
	    $my_postid = 15304; // Enter ID of page to append
	    $post_object = get_post( $my_postid );
            $new_content1 = $post_object->post_content;
        
            $content .= $new_content1;
	}	
	return $content;
}
add_filter('the_content', 'wmhb_filter_content1');

This is my attempt at incorporating your example. This does not work- no content is returned.

function wmhb_filter_content1($content) {
	
	$td_smart_list = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
	
	if (!empty($td_smart_list['smart_list_template'])) {
		
	    $my_postid = 15304; // Enter ID of page to append
	    $post_object = get_post( $my_postid );
        $new_content1 = $post_object->post_content;
        
		$content .= $new_content1;
	}	
	return $content;
}
add_filter('the_content', 'wmhb_filter_content1');

I realize this is out of scope for the support you provide but if you can assist me in getting this to work I’ll be very grateful!

  • This reply was modified 10 years by five40.
Post count: 23312

Hello five40,

Please notice that this is a task which falls beyond the support can offer you at the moment. We would have gladly made it for you but we are a small team and we are working very hard on the development, updates, fixes, and support and basically, we do not have the time required to accomplish that kind of complex task.

Thank you for your understanding!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.