Using WP functions such as the_title() in an included php file
Get the title into a variable, and use the variable in the included PHP instead: $title = get_the_title(); include “yourfile.php”; yourfile.php: <?php echo $title; ?>
Get the title into a variable, and use the variable in the included PHP instead: $title = get_the_title(); include “yourfile.php”; yourfile.php: <?php echo $title; ?>
Your idea of using the current date in the filename would be the easiest. In the template for your page, you could have the following to generate your current day link: <a href=”https://wordpress.stackexchange.com/path/to/file/filename_<?php echo date(“Y-m-d’) ?>.pdf”>Today’s file</a> The above uses the PHP date function to create a filename with the current date appended to it … Read more
The code below works, basically it adds your class to the wordpress body_class() array.. add_filter(‘body_class’,’my_class_names’); function my_class_names($classes) { // add ‘class-name’ to the $classes array $classes[] = ‘mobile’; // return the $classes array return $classes; } You can read more on this on the WP codex here
You need to do three things: firstly, your markup is incorrect, take the container_24 div the main content sits in and make it grid_17 so it doesn’t take up the entire width of the container div. The sidebar needs to go in the container div along with the content, else it will be pushed downwards … Read more
Check this wp_set_object_terms().
The problem is that you are using file_get_contents() which only gets the content of the file (hence the name) if you need to render(evaluate and process the php file) then just use include(). But also if your cup_bc_layout.php file echo’s out something then you should put the include inside an object buffer and then return … Read more
strip_tags — Strip HTML and PHP tags from a string if (!empty($post->post_excerpt)) { $excerpt_raw = strip_tags(get_the_excerpt()); echo $excerpt_raw; }
Yes it’s possible, just use the is_user_logged_in() function as descibed in the codex for this. It would go like this: <?php if ( is_user_logged_in() ) { echo “you are logged.”; } else { echo “You are not logged”; } ?>
Ok, well it turns out it has more to do with WordPress then we realised. The wp_link_pages function, in which the hook being used in the question resides, is the culprit rather than anything you’ve done. If you want to have a look, the function is in the post-template.php file inside the wp-includes directory. The … Read more
$count = 1; is set in the while loop, so every time the loop runs it sets to 1 again. Place it before your loop and it will work. $count = 1; if (have_posts()) : while (have_posts()) : the_post(); Ow and the $count++ is outside the loop so it will only run after all the … Read more