How to get links to the last N posts in a specific category?

First, there is no parameter named cat in get_posts. Use category instead to input comma separated category IDs or category_name to directly inserting category name. Second, in your code you have commented out the title of the post. Try this code. <?php $cat_id = get_cat_ID(‘category1’); $posts = get_posts( “category=$cat_id&posts_per_page=3” ); if ($posts) { foreach ($posts … Read more

Echo title with permalink

This is the problem: $link = the_permalink(); Replace it with: $link = get_permalink(); Notice that the WordPress the_* functions will echo the output, but get_* will return it. But of course there are exceptions to this rule 😉 So you don’t need this: echo the_title(); Just use this instead: the_title(); or the usage example given … Read more

How to show show the Second page title in the page

get_post_ancestors() returns all of the ancestors hierarchically. As you only want to display the 2nd level post title on 4th post page, you can do something like – global $post; $parents = get_post_ancestors( get_the_ID() ); if( count($parents) == 4 ){ // ancestor1 = 1st parent, ancestor2 = second. echo get_the_title($parents[‘1’]); // index starts from 0, … Read more

Add the title attribute to links

Turns out you are not the only one: https://core.trac.wordpress.org/ticket/32095 It looks like this was removed in a recent update (4.2) and I can see why they did it. User interface can be confusing at times. You can read more about the removal here: http://wptavern.com/how-to-restore-the-link-title-attribute-removed-in-wordpress-4-2 There is a WordPress plugin, however, that seems to add it … Read more

Run str_replace on title and save the output to a custom field

the_title_rss() outputs its value straight away so it can’t be used in a function like that, you would have to use get_the_title_rss() Or alternatively the_title_rss() has a filter we can hook in to and return your shortened title is possible. (You would add this to your functions.php) function gg_short_title_rss($title) { // This can return false, … Read more

Function extending with if query in functions.php

may be it’s clearer like this : add_filter(‘wpseo_set_title’, function ($title) { if (is_single()) { $page_comment = get_query_var(‘cpage’); if ($page_comment > 3) { $title = “Kontroverse Diskussionen zu: $page_comment $title”; } elseif ($page_comment > 0) { $title = “Meinungen zu: $page_comment $title”; } } return $title; });

Reduce size of responsive title

You can add custom CSS where you use media query in order to reduce the font-size of the title in small devices. You also have some styling that remove the line break and add the 3 dots at the end. So you can also remove them. You can try this code : @media all and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)