• Resolved Alph

    (@alpph)


    Hi

    I create Custom Post Types (CPT) and Custom Fields (CF) with Toolset Types from OnTheGoSystems.

    CPT slug is ‘types_recette’ and one CF slug is ‘sous_titre’

    I modified the content.php file in the child theme to display all the fields of CPT ‘types_recette’.

    I can display what I want from my CPT with Advanced Post List without the values of the custom fields.

    How can I do that ?

    Thanks for your answer

    • This topic was modified 6 years, 9 months ago by Alph.
    • This topic was modified 6 years, 9 months ago by Alph.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author EkoJR

    (@ekojr)

    I haven’t used APL in that sort of environment, but the Internal Shortcodes are primarily for Built-in Post values.

    However, if you do want to add custom fields. There is also a custom php shortcode.

    Currently, most of the information and documentation for APL has been getting added to the GitHub Wiki. It’s a work-in-progress, but 0.4 is likely to have new documentation that correlates to it.

    Thread Starter Alph

    (@alpph)

    Hi,

    Thanks for your help. I understand the working of php_function.

    This works :

    [php_function name="my_custom_field"]

    function my_custom_field () {
    $retour = '';
    if (types_render_field( "sous_titre",  array( ) ) )  {
       $retour =  (types_render_field( "sous_titre", array( 'raw' => true) )); };
    return $retour ;
    }

    But this does not works :

    [php_function name="my_custom_field" param="sous_titre"]

    function my_custom_field ($field_name) {
    $retour = '';
    if (types_render_field( $field_name,  array( ) ) )  {
       $retour =  (types_render_field( $field_name, array( 'raw' => true) )); };
    return $retour ;
    }

    Any Idea that can help ?

    Thanks

    Plugin Author EkoJR

    (@ekojr)

    The first param MUST be a WP_Post variable $post. I think that may solve your issue.

    I also recently finished writing a Tutorial on PHP_Function Shortcode.

    Thread Starter Alph

    (@alpph)

    Hi,

    function my_custom_field ( $post, $myfield ) {
      $retour = '';
    	if (types_render_field(  $myfield ,  array( ) ) )  {
    		 $retour .=  (types_render_field( $myfield , array( 'raw' => true) ));
    	} ;
      return $retour ;
    }

    That works. Hurrah !!

    I reword your answer : there is an implicit first parameter $post, the param passed with [php_function…] is in fact the second parameter.

    Please add a example with <param = “Something”> in your tutorial.

    Thanks

    • This reply was modified 6 years, 9 months ago by Alph.
    • This reply was modified 6 years, 9 months ago by Alph.
    • This reply was modified 6 years, 9 months ago by Alph.
    Thread Starter Alph

    (@alpph)

    Hi,

    Just a question : How to pass more as one parameter ?

    Thanks

    Plugin Author EkoJR

    (@ekojr)

    Currently, there can only be 1 param passed. I haven’t had any need for it, although I think I remember contemplating a redesign at one point, and I thought about passing an array of params, but I wanted to keep it simple for others, and prior to 0.3.2 it wasn’t a possibility to implement multiple parameters.

    Thinking it over:

    • I can’t changed too much with others already using the php_function.
    • I don’t want to add additional call to function params. If I did, it would be 3, but then there would be the confusion with php param erros.
    • The param type will always be a string due to how WP saves the data

    With that in mind, I did have another thought. Add the whole shortcode attribute array as the 3rd param, and let others handle the data on their own; this method is actually relatively easy for others to do. This would offer both a novice, and an advanced method which would have to handled its own set of data accordingly.

    • This reply was modified 6 years, 9 months ago by EkoJR.
    Thread Starter Alph

    (@alpph)

    Hi,

    I finished the transition from an other plugin with the same functions, but with no update since a long time.

    See :

    http://www.papinette.fr/?page_id=300

    About more that one param, it was just a question for completness. I don’t need it.

    I will put a request for an add : a More function in the lists. Curently I don’t need it, but with more than 100 posts, a list will be very long.

    Thanks for all

    • This reply was modified 6 years, 9 months ago by Alph.
    • This reply was modified 6 years, 9 months ago by Alph.
    Plugin Author EkoJR

    (@ekojr)

    I just noticed you made a post here, and realized the GitHub issue was related. Slightly confused to what is being said.

    I am curious, what is the other plugin that you were using prior to APL?

    Thread Starter Alph

    (@alpph)

    I complete the Github issue with a screenshot to explain what I mean.

    Prior I was using Custom Content Shortcode

    There are no updates and no support since one year, and some shortcodes do not work any more with the last version of WP.

    Plugin Author EkoJR

    (@ekojr)

    Interesting…that’s the first time I’ve heard of that plugin, and it appears to apply many of the same concepts APL has. In APL’s case, majority of the configurations are applied on the admin side as a Preset, instead of a collection of shortcodes and/or shortcode attributes. Which is one of the things I always preferred in order to make APL a bit more manageable instead of making a muck out of things.

    The other plugin does seem to have very high ratings, and I’m kind of curious what made it unique. Perhaps if I get some time spare time I’ll check it out.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Custom fields’ is closed to new replies.