Call php file in html content at header bar

Home Forums Pro Support Call php file in html content at header bar

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #69978
    Hiro CWHiro CW
    Participant

    Hi I love this plugin.

    I have used php in html content at header bar. Using short code to call php file.

    It works really good, but I got stacked when I set below code as sub-loop.

    <?php
    $posts =get_posts(array(
        'numberposts' => -1, 
        'category_name' => 'puppy',
        'order' => 'ASC',
    ));
    ?>
    <?php wp_reset_postdata(); ?>

    I use this code to show some values of custom field.

    When I set this code on single.php, I can not get correct post_id only at html content space of Responsive menu pro.

    It does not show correct post_id, and it shows very first post_id that belongs to the category of puppy in above case.

    Is there any way to solve this problem?

    #69984
    Kriti SharmaKriti Sharma
    Keymaster

    Hi,

    Welcome to Responsive Menu Support Forum. Hopw you are doing good.

    I am forwarding your issue to the development team. I will be back to you soon.

    Regards,
    Kriti

    #69989
    Kriti SharmaKriti Sharma
    Keymaster

    Hi,

    This has nothing to do with our plugin.

    In a WordPress theme, in order to show a value from post meta or custom field, you need to use the function get_post_meta

    get_post_meta()

    Which by default will use the post id of a particular post, if it is in single.php

    If not, you will need to provide the post id.

    In single.php of a theme, there is only the post id of that particular post in the global $post variable.

    There is nothing wrong with this. To show a list of posts in a category, you need to use WP_Query class ( https://developer.wordpress.org/reference/classes/wp_query/ )

    For example.

    https://www.isitwp.com/display-other-posts-from-the-same-category/

    We suggest you to ask for help in WordPress.org forum, if you requires further assistance.

    Regards,
    Kriti

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.