• I know the executive level summary of what happens. A variable in the URL is pulled, and it uses that to match up stories in the db that have the same post_title. However, this isn’t flexible and I want the variable to be matched up with a meta instead of the post_title. But I’m not sure how to do this. Below is the code that should handle this. Does anyone have any idea on this is working?

    if ($_GET['symbol']) {
    		add_filter( 'posts_where', 'filter_where_title' );
    	}
    	function filter_where_title($where = ' ') {
    		$where .= ' AND post_title = "'.strtoupper($_GET['symbol']).'"';
    		return $where;
    	}

    To be honest I don’t have a clear understanding of what actually happens here. My first guess is that the code is executing a SQL query. “AND post title = ‘GETVARIABLEFROMURL'” , however I have no idea where that query lives….

Viewing 1 replies (of 1 total)
  • Thread Starter phpchick

    (@phpchick)

    I replaced the above portion with

    if ($_GET['symbol']) {
    		$args['meta_query'][] = array(
    			'key' => 'symbol',
    			'value' => $_GET['symbol'],
    			'compare' => '='
    		);
    	}

    and it seems to work

    [No bumping, thank you.]

Viewing 1 replies (of 1 total)
  • The topic ‘Help with identifying function of this snippet?’ is closed to new replies.