• Resolved DaveWP196

    (@davewp196)


    It is not clear from the documentation what the full effect of the setup_ec_data routine on which of the standard wordpress functions are available.
    For example, after calling setup_ec_data, what should be the effect of calling the_title() function.

    What I am after is a working example of

    • calling setup_ec_data and outputting a category
    • outputing a category title
    • the category description
    • the first 2 posts associated with the category

    I’ve looked at the code of setup_ec_data routine and not clear which of the standard functions will work as some depend on WP_Query which is not changed using setup postdata(). In particular is_category() function does not work as it relates to original page.

    https://www.ads-software.com/plugins/enhanced-category-pages/

Viewing 1 replies (of 1 total)
  • Plugin Author cip

    (@cip)

    Hi!

    Thank you for finding the plugin useful.

    To answer your questions now, we are setting the current post, so all functions/template tags that are available in “the loop“. Here is the reference of WordPress Post tags: https://codex.www.ads-software.com/Template_Tags#Post_tags

    So, once you call setup_ec_data the current post is set to the custom post type associated with the category/term. Then you can call template tags/functions such as:

    • the_ID()
    • post_class()
    • the_post_thumbnail
    • the_content()
    • the_title()
    • the_meta()
    • the_date()
    • comments_template()
    • etc.

    To get the first two posts from current category:

    $enhanced_category->setup_ec_data(); //optionally you can send a category ID
    $filter = array( 'category' => get_the_ID(), 'posts_per_page' => 2 );
    $posts = get_posts($filter);

    Also you can use views/ecp_category_description.php as a source of inspiration.

    I hope this answers your questions and would appreciate showing your gratitude by rating our plugin.

    Cheers!

Viewing 1 replies (of 1 total)
  • The topic ‘setup_ec_data and wordpress functions’ is closed to new replies.