WordPress.org

Ready to get started?Download WordPress

Forums

MapPress Easy Google Maps
Function to show something else if no map for Post (1 post)

  1. TrishaM
    Member
    Posted 7 months ago #

    Love this plugin! :-)

    Can someone suggest some PHP to use with the shortcode in my Theme so that if no map is entered for a Post, I can display something else (a default image I will create)?

    Right now in my Theme file that displays the page for a specific category of Posts, I'm using:
    ~<?php echo do_shortcode('[mappress]'); ?>~

    I'm not a coder, but I do know how to modify themes and PHP, and use code provided to get the results I need. Also, I know how to query for metadata in wp_postmeta and act on the results, but the MapPress data is in it's own tables so I'm not entirely sure how to structure a query that would let me do one thing if there is no map, and another if there is…..I'm thinking something along the lines of:

    ~ if ( !$mapid ==' ' ) {
    echo do_shortcode('[mappress]'); }
    else {
    echo <img src="mydefaultimage" /> }
    ~

    But as I said, I'm not a coder.

    Any suggestions?

    https://wordpress.org/plugins/mappress-google-maps-for-wordpress/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.