How to store the_title() into a variable to reutrn the value, not just echo it
You can use get_the_title() to return the current post title in the loop.
You can use get_the_title() to return the current post title in the loop.
Those are the Mustache-inspired syntax you are talking about. That can be acheived using wp.template WordPress function. The script you showing is javascript templating in WordPress wp.template() is a cool little JavaScript utility method WordPress uses this utility to load templates for all of the backbone views, but backbone is not required to use it. … Read more
This is a good question, a year back or so, even I was facing similar problems with a website at work. We wanted to track not only campaign and ads on conversions, but also which keywords are leading to higher conversions. Here’s what we finally did. Changed the Destination URL in all the ads to … Read more
Just check if the variable is set, using the code from your link: add_action( ‘init’, ‘set_agent_cookie’ ); function set_agent_cookie() { if (isset($_GET[‘code’])) { $name=”agent”; $id = $_GET[‘code’]; setcookie( $name, $id, time() + 3600, “https://wordpress.stackexchange.com/”, COOKIE_DOMAIN ); } }
I pretty sure this filter lets you add an array of variables. I’ve not tested this: function add_custom_query_vars( $vars ){ $vars[] = “variable1”; $vars[] = “variable2”; $vars[] = “variable3”; //… etc return $vars; } add_filter( ‘query_vars’, ‘add_custom_query_vars’ ); Or another way of doing it would be to do this: function add_custom_query_vars( $vars ){ array_push($vars, “variable1”, … Read more
The WordPress template functions don’t support passing variables (to my knowledge) by default, so you need to write your own function. For example like this, // functions.php function my_template_include_with_variables( string $path=””, $data = null ) { $file = get_template_directory() . “https://wordpress.stackexchange.com/” . $path . ‘.php’; if ( $path && file_exists( $file ) ) { // … Read more
Getting meta data from a WP_Post object is already possible. Just write: echo $post->your_meta_key; This will call get_post_meta( $this->ID, $your_meta_key, true ) behind the scenes. See the documentation and the source code for WP_Post. This works also with instances of WP_User, but not with WP_Comment as far as I know. Don’t forget to escape the … Read more
I figured out a solution to my question. First of all, in my original query, I should have specified OR instead of AND for searching between group names and group descriptions. (It was skewing the results.) And I needed to double escape my ‘%’s in the LIKE statements. Here is the updated query which works … Read more
Why do you need this? In wp-config you can set defines. They will be accesible everywhere without needing to use globals. Define something: define(‘MY_DEFINE_NAME’, ‘THE_VALUE’);. Then in your templates you can show the value like this: echo MY_DEFINE_NAME; Or set the value to a variable: $var = MY_DEFINE_NAME;.
In simple words – it will tell wordpress what to query (to request a data from database). in all of cases it will try to search a posts (no mater post this or page or other post type) http://dmkim.ru/?s=uuu – eq search uuu on posts (default post type post & pages) and return a results … Read more